Set an alias for the command.
Command for chaining
Get alias for the command.
Allow unknown options on the command line.
Command for chaining
Define argument syntax for the top-level command.
Command for chaining
Define a command, implemented using an action handler.
command name and arguments, args are <required>
or [optional]
and last may also be variadic...
configuration options
new command
Define a command, implemented in a separate executable file.
command name and arguments, args are <required>
or [optional]
and last may also be variadic...
description of executable command
configuration options
top level command for chaining more command definitions
Set the description.
Command for chaining
Get the description.
Register callback to use as replacement for calling process.exit.
Output help information and exit.
You can pass in flags and a description to override the help flags and help description for your command.
Set the name of the command.
Command for chaining
Get the name of the command.
Define option with flags
, description
and optional
coercion fn
.
The flags
string should contain both the short and long flags,
separated by comma, a pipe or space. The following are all valid
all will output this way when --help
is used.
"-p, --pepper" "-p|--pepper" "-p --pepper"
Command for chaining
Return an object containing options as key-value pairs
Output help information for this command.
When listener(s) are available for the helpLongFlag those callbacks are invoked.
Parse argv
, setting options and invoking commands when defined.
Command for chaining
Parse argv
, setting options and invoking commands when defined.
Use parseAsync instead of parse if any of your action handlers are async. Returns a Promise.
Promise
Parse expected args
.
For example ["[type]"]
becomes [{ required: false, name: 'type' }]
.
Command for chaining
Parse options from argv
returning argv
void of these options.
Whether to pass command to action handler, or just the options (specify false).
Command for chaining
Define a required option, which must have a value after parsing. This usually means the option must be specified on the command line. (Otherwise the same as .option().)
The flags
string should contain both the short and long flags, separated by comma, a pipe or space.
Whether to store option values as properties on command object, or store separately (specify false). In both cases the option values can be accessed using .opts().
Command for chaining
Set the command usage.
Command for chaining
Get the command usage.
Set the program version to str
.
This method auto-registers the "-V, --version" flag which will print the version number when passed.
You can optionally supply the flags and description to override the defaults.
Register callback
fn
for the command.program .command('help') .description('display verbose help') .action(function() { // output help here });