Skip to content

Commit 857c1e2

Browse files
SahilKangmfikes
authored andcommitted
CLJS-2652: Line breaks in long options for compile
This patch prevents line-breaking in the middle of long-form option descriptions by treating long-form options as single tokens, instead of considering `--` as its own token. Running `cljs --help` without this patch would produce output looking like (notice the line-break between `--` and `compile`: * Set optimization level, only effective with -- compile main option. Valid values are: none, whitespace, simple, advanced With this patch, the output looks like: * Set optimization level, only effective with --compile main option. Valid values are: none, whitespace, simple, advanced
1 parent c7fa4a6 commit 857c1e2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main/clojure/cljs/cli.clj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ classpath. Classpath-relative paths have prefix of @ or @/")
6060
(let [w (.substring ws s e)
6161
word-len (.length w)
6262
line-len (+ line-len word-len)]
63-
(if (> line-len max-len)
64-
(recur e (.next b) word-len w (conj ret line))
65-
(recur e (.next b) line-len (str line w) ret)))
63+
(if (= w "--") ; long-form options are single tokens (i.e. --repl)
64+
(recur s (.next b) (- line-len 2) line ret)
65+
(if (> line-len max-len)
66+
(recur e (.next b) word-len w (conj ret line))
67+
(recur e (.next b) line-len (str line w) ret))))
6668
(conj ret (str line (.substring ws s (.length ws)))))))))
6769

6870
(defn- opt->str [cs {:keys [arg doc]}]

0 commit comments

Comments
 (0)