Hi all! Trying to use clojure.tools.cli to help us parse command line arguments. However we are having trouble understanding how to specify required arguments.
The following example taken from the documentation ( https://github.com/clojure/tools.cli#quick-start) should give a required argument (but we have commented out default value). However errors is nil: (def cli-options ;; An option with a required argument [["-p" "--port PORT" "Port number" ; :default 80 :parse-fn #(Integer/parseInt %) :validate [#(< 0 % 0x10000) "Must be a number between 0 and 65536"]] ;; A non-idempotent option ["-v" nil "Verbosity level" :id :verbosity :default 0 :assoc-fn (fn [m k _] (update-in m [k] inc))] ;; A boolean option defaulting to nil ["-h" "--help"]]) ;=> (var user/cli-options) (:errors (parse-opts [] cli-options)) ;=> nil Actually giving it a value will give an error though: (:errors (parse-opts ["--port" ""] cli-options)) ;=> ["Error while parsing option \"--port \": java.lang.NumberFormatException: For input string: \"\""] >From the documentation it seems that specifying the second part of the "long option" should be enough to make an argument required. So this minimal example should also produce errors: (def cli-options-simplified [["-p" "--port PORT" "Port number"]]) ;=> (var user/cli-options-simplified) (:errors (parse-opts [] cli-options-simplified)) ;=> nil So what are we misunderstanding? Any pointers would be greatly appreciated. Using Clojure 1.5.1 with tools.cli 0.3.1. Cheers, Alf -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.