Skip to content

Commit 3918301

Browse files
committed
fix explanation of :missing in README
1 parent b39f7f1 commit 3918301

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,14 @@ and returns them to the caller. Unknown options, missing required arguments,
202202
validation errors, and exceptions thrown during `:parse-fn` are all added to
203203
the errors vector.
204204

205-
By default, the error message when a required argument is omitted is:
205+
Any option can be flagged as required by providing a `:missing` key in the
206+
option spec with a string that should be used for the error message if the
207+
option is omitted.
206208

207-
`Missing required argument for ...`
209+
The error message when a required argument is omitted (either a short opt with
210+
`:require` or a long opt describing an argument) is:
208211

209-
This can be overridden by providing a `:missing` key in the option spec with a
210-
string that should be used for the error message instead of the default.
212+
`Missing required argument for ...`
211213

212214
Correspondingly, `parse-opts` returns the following map of values:
213215

src/main/clojure/clojure/tools/cli.cljc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,12 @@
413413
:else
414414
(validate value spec opt optarg))))
415415

416-
(defn- neg-flag? [spec opt]
416+
(defn- allow-no? [spec]
417417
(and (:long-opt spec)
418-
(re-find #"^--\[no-\]" (:long-opt spec))
418+
(re-find #"^--\[no-\]" (:long-opt spec))))
419+
420+
(defn- neg-flag? [spec opt]
421+
(and (allow-no? spec)
419422
(re-find #"^--no-" opt)))
420423

421424
(defn- parse-optarg [spec opt optarg]

0 commit comments

Comments
 (0)