l3nz / cli-matic

Compact, hands-free [sub]command line parsing library for Clojure.
Eclipse Public License 2.0
361 stars 29 forks source link

Support true/false keywords: "true" -> :true "false" -> :false #68

Closed WhittlesJr closed 4 years ago

WhittlesJr commented 5 years ago

Previously:

(cli/parse-cmds ["--opt1" "true" "test"]
                {:global-opts [{:option "opt1" 
                                :short  "o"
                                :type   :keyword}]
                 :commands    [{:command "test"}]})
=>
{:subcommand "test",
 :subcommand-def {:command "test"},
 :commandline {:opt1 nil, :_arguments []},
 :parse-errors :NONE,
 :error-text ""}
WhittlesJr commented 5 years ago

Of course, you'd think that an option that someone would pass "true" or "false" to should be a true boolean flag (yet to be implemented), but :keyword should behave the same no matter what the word is.

l3nz commented 5 years ago

Makes sense - can you add the changes for the docs as well? and maybe a script as per https://github.com/l3nz/cli-matic/blob/master/CONTRIBUTING.md ? (I wrote Contribs today so it can definitely be improved!)

l3nz commented 4 years ago

Won't merge as the issue has been fixed.