Allows saving name of used command in a field of result target.
Helpful when command callbacks are stored in a table with names as keys
or when they are in submodules of some namespace.
Example:
local parser = argparse():command_target("command")
-- Add commands...
local args = parser:parse()
require("namespace." .. args.command).run(args)
* For arguments: "argument 'foo' is required" -> "missing argument 'foo'"
* For options: "option '--foo' must be used at least 1 time" ->
"missing option '--foo'"
* Use state objects instead of tons of locals in the main
function.
* Use actions for storing arguments into result table.
Actions are now called at the end of each invocation,
with result table, target index, arguments and overwrite flag as
arguments.
* Remove command actions.
* Improve error messages, refer to options by the last used alias
instead of the main name.
TODO:
* Improve error messages further ("argument 'foo' is required"
-> "missing argument 'foo'", etc.).
* Add actions for positional arguments.
* Add actions for commands (should be called with final results
after parsing is over, in "innermost first" order).
* Allow referring to built-in actions by strings a-la Python
(e.g. action = "store_false").
* Allow setting initial value to be stored at target index
for each option (perhaps use default value for that).
* Add more tests, particularly for actions.
When `parser:handle_options(true)` (the default), the parser will behave as
before.
When `parser:handle_options(false)`, all options will be passed verbatim
to the argument list, as if the input included double-hyphens.
Move more common properties to the front of property lists,
so that they can be passed as constructor arguments.
E.g.
parser:option "-p" "--port"
:description "Port number."
:default "8080"
:convert(tonumber)
can now be expressed as
parser:option("-p --port", "Port number.", "8080", tonumber)
Allow setting several names using 'name' property instead, e.g.
':name "-f --foo"' instead of ':aliases {"-f", "--foo"}'.
This change breaks documented interface of 0.3.x.
Disable undocumented ability to specify aliases as arguments
for constructors, e.g. parser:option("-f", "--foo"), and instead
order properties and pass constructor arguments to them.
E.g. parser:argument("foo", "A foo that bars") sets argument
name to foo and description to "A foo that bars".
TODO: remove "aliases" property, instead allow setting several
names in one string by separating them using space.
TODO: reorder properties so that most useful ones could be used
as constructor arguments.