Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compiled option specifications are a vector of: {:id Keyword ; :server :short-opt String ; \"-s\" :long-opt String ; \"--server\" :required String ; \"HOSTNAME\" :desc String ; \"Remote server\" :default Object ; #<Inet4Address example.com/93.184.216.119> :default-desc String ; \"example.com\" :parse-fn IFn ; #(InetAddress/getByName %) :assoc-fn IFn ; assoc :validate-fn IFn ; (partial instance? Inet4Address) :validate-msg String ; \"%s is not an IPv4 host\" } The vector option spec format is desugared into the map above. All entries are overridable, allowing for fine control of the resulting option map after parsing an args sequence. Additions from cli/cli include: :default-desc A string that is used to represent the default value, in case the string representation of the default is too ugly to be printed in help output. :required All options are considered boolean flags by default, unless this value is truthy. The value if present should be a string that will be printed as an example required argument to the option. :validate-fn Validates required option arguments *after* being parsed by parse-fn. Exceptions are caught and return nil. :validate-msg If validate-fn returns a falsy value, validate-msg is conjed onto the parse-opts :errors vector. cli/compile-option-specs asserts the presence of an :id value in every map, as well as the uniqueness of all :id, :short-opt, and :long-opt values.
- Loading branch information
Showing
2 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters