A single element in the cli-options can be as brief as
["-p" "--port" "A port number"]
What is non-obvious is that specifying
"--port PORT"
has entirely different semantics than specifying
"--port"
In the first case the command "lein run -p 3000" will result in an options
map of {:options {:port 3000}}.
Can you guess what the same command would produce given the second case?
If you're like me, you wouldn't guess {:options {:port true}}. :-/
It is worth noting that in earlier versions of this library "--port" did
result in {:options {:port 3000}}, so this is a change in behavior from
previous versions.
The current behavior is neither simple nor easy to understand, and
complects the behavior of the flag with the definition of the long option.
I suggest that this implicit behavior be removed and that all options be
treated as required unless ":required false" is explicitly declared.
Or perhaps there should be :boolean flag similar to :parse-fn or :default,
since :required feels a little overloaded.
That way given "lein run -p 3000", ["-p" "--port" "A port number"] would
result in {:options {:port 3000}} and
["-p" "--port" "A port number" :boolean true] would result in {:options
{:port true}}.
That would make when a flag will be treated as a boolean explicit and
obvious, and make this library a little less frustrating and foot-gunish.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.