argparser.command

argparser

command(name, opts) -> cmd

Create a new command parser with options, arguments, and subcommands

Returns a command object with chainable builder methods:

The opts table accepts default_subcommand (string) and subcommand_required (boolean, defaults to true).

Option spec

Fields for the spec table passed to cmd:option(name, spec):

Argument spec

Fields for the spec table passed to cmd:argument(name, spec):

Parse return

On success, cmd:parse(argv) returns (parsed, nil) where parsed is a table keyed by option/argument names. When subcommands are used, parsed also contains subcommand (name) and args (sub-parsed table).

On failure or help, returns (nil, err) where err is a table: