janet-lang / spork

Various Janet utility modules - the official "Contrib" library.
MIT License
122 stars 35 forks source link

fixed docstring of argparse and added collection of unparsed arguments #138

Closed tionis closed 1 year ago

tionis commented 1 year ago

The :short-circuit option in argparse does not let the parsing fail, as only the internal usage function sets the var bad to true. I corrected this in the docstring and also added a step that collects the rest of the arguments when hitting the :short-circuit flag. This should allow people to implement subcommands more easily using something like :default {:kind :accumulate :short-circuit true} to parse args per subcommand.

Currently, :rest includes the flag that short-circuited, while this does make it easier to implement subcommands with their own arg parsing it might be a bit unexpected for some.