Share your thoughts in the 2024 State of Clojure Survey!

Welcome! Please see the About page for a little more info on how this works.

+1 vote
in tools.cli by

The :validate option currently takes a validation function and a string error message.

Could we extend the second argument to a function instead so you can return an error message like "--foo should be greater than 10, but was: 11.

We could even plug clojure.spec.alpha or malli in there:

(def cli-options
  [["-n" "--number NUM" "A number"
    :parse-fn (m/decoder int? mt/string-transformer)
    :validate [(fn [input]
                 (m/validate [:< 100] input))
               (fn [input]
                 (me/humanize (m/explain [:< 100] input)))]]])

1 Answer

0 votes
by
selected by
 
Best answer
...