keen/parse-command
Sourceparse-command-error recordparse-command parsed-command(args string[])See comment on
parsed-command for syntax. Parse errors aren't possible with this syntax.parse-named-args string[] option[] option(args string[], arg-names symbol[])This is stricter than parse-command. It expects only named arguments, and only the names in arg-names are allowed.
Returns an array with an entry for each name in arg-names. Values in the array will be a list of the argument values, or an empty option if the corresponding argument name did not appear.
For example, if the command line is "--a --c d" and arg-names are ("a", "b", "c"), This will return ((),) (), (("d",),).
If the argument syntax is invalid, returns an empty option.
single-string-or-throw string(strings string[] option, option-name string)If a is a single element, returns that; else throws a parse-command-error.
Useful for arguments that should have a single string as their value.
In this syntax: * Each name starting with
--is an argument name, and words after that are its argumets. * Everything before the first named argument will be left unparsed and put innameless. * Everything after--will be left unparsed and put inafter.For example, if the command is:
foo bar --a 1 --b 2 3 -- x y z:namelesswill be:"foo", "bar"namedwill be:("a", (1,)), ("b", (2, 3))afterwill be:"x", "y", "z"