Optionalname: stringReadonlycommandsReadonlyoptionsReadonlyregisteredDefine argument syntax for command, adding a prepared argument.
this command for chaining
Add a prepared subcommand.
See .command() for creating an attached subcommand which inherits settings from its parent.
Optionalopts: CommandOptionsthis command for chaining
Override default decision whether to add implicit help command.
OptionalenableOrNameAndArgs: string | booleanOptionaldescription: stringthis command for chaining
Add additional text to be displayed with the built-in help.
Position is 'before' or 'after' to affect just this command, and 'beforeAll' or 'afterAll' to affect this command and all its subcommands.
Add additional text to be displayed with the built-in help.
Position is 'before' or 'after' to affect just this command, and 'beforeAll' or 'afterAll' to affect this command and all its subcommands.
Add a prepared Option.
See .option() and .requiredOption() for creating and attaching an option in a single call.
Set an alias for the command.
You may call more than once to add multiple aliases. Only the first alias is shown in the auto-generated help.
this command for chaining
Get alias for the command.
Set aliases for the command.
Only the first alias is shown in the auto-generated help.
this command for chaining
Get aliases for the command.
Allow excess command-arguments on the command line. Pass false to make excess arguments an error.
OptionalallowExcess: booleanthis command for chaining
Allow unknown options on the command line.
OptionalallowUnknown: booleanthis command for chaining
Define argument syntax for command.
The default is that the argument is required, and you can explicitly indicate this with <> around the name. Put [] around the name for an optional argument.
this command for chaining
Define argument syntax for command.
The default is that the argument is required, and you can explicitly indicate this with <> around the name. Put [] around the name for an optional argument.
Optionaldescription: stringOptionaldefaultValue: unknownthis command for chaining
Alter parsing of short flags with optional values.
Optionalcombine: booleanthis 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...
Optionalopts: CommandOptionsconfiguration 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
Optionalopts: ExecutableCommandOptionsconfiguration options
this command for chaining
You can customise the help by overriding Help properties using configureHelp(), or with a subclass of Help by overriding createHelp().
Get configuration
The default output goes to stdout and stderr. You can customise this for special applications. You can also customise the display of errors by overriding outputError.
The configuration properties are all functions:
// functions to change where being written, stdout and stderr
writeOut(str)
writeErr(str)
// matching functions to specify width for wrapping help
getOutHelpWidth()
getErrHelpWidth()
// functions based on what is being written out
outputError(str, write) // used for displaying errors, and not used for displaying help
Get configuration
Copy settings that are useful to have in common across root command and subcommands.
(Used internally when adding a command using .command() so subcommands inherit parent settings.)
Factory routine to create a new unattached argument.
See .argument() for creating an attached argument, which uses this routine to create the argument. You can override createArgument to return a custom argument.
Optionaldescription: stringFactory routine to create a new unattached command.
See .command() for creating an attached subcommand, which uses this routine to create the command. You can override createCommand to customise subcommands.
Optionalname: stringYou can customise the help with a subclass of Help by overriding createHelp, or by overriding Help properties using configureHelp().
Factory routine to create a new unattached option.
See .option() for creating an attached option, which uses this routine to create the option. You can override createOption to return a custom option.
Optionaldescription: stringSet the description.
this command for chaining
Get the description.
Enable positional options. Positional means global options are specified before subcommands which lets subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions.
The default behaviour is non-positional and global options may appear anywhere on the command line.
Optionalpositional: booleanthis command for chaining
Display error message and exit (or call exitOverride).
OptionalerrorOptions: ErrorOptionsGet the executable search directory.
Register callback to use as replacement for calling process.exit.
Optionalcallback: (err: CommanderError) => voidRetrieve option value.
Get source of option value.
Get source of option value. See also .optsWithGlobals().
Output help information and exit.
Outputs built-in help, and custom text added using .addHelpText().
Optionalcontext: HelpContextReturn command help documentation.
Optionalcontext: HelpContextYou can pass in flags and a description to override the help flags and help description for your command. Pass in false to disable the built-in help option.
Optionalflags: string | booleanOptionaldescription: stringSet the name of the command.
this command for chaining
Get the name of the command.
Add a listener (callback) for when events occur. (Implemented using EventEmitter.)
Define option with flags, description, and optional argument parsing function or defaultValue or both.
The flags string contains the short and/or long flags, separated by comma, a pipe or space. A required
option-argument is indicated by <> and an optional option-argument by [].
See the README for more details, and see also addOption() and requiredOption().
Optionaldescription: stringOptionaldefaultValue: string | boolean | string[]this command for chaining
program
.option('-p, --pepper', 'add pepper')
.option('-p, --pizza-type <TYPE>', 'type of pizza') // required option-argument
.option('-c, --cheese [CHEESE]', 'add extra cheese', 'mozzarella') // optional option-argument with default
.option('-t, --tip <VALUE>', 'add tip to purchase cost', parseFloat) // custom parse function
Define option with flags, description, and optional argument parsing function or defaultValue or both.
The flags string contains the short and/or long flags, separated by comma, a pipe or space. A required
option-argument is indicated by <> and an optional option-argument by [].
See the README for more details, and see also addOption() and requiredOption().
this command for chaining
program
.option('-p, --pepper', 'add pepper')
.option('-p, --pizza-type <TYPE>', 'type of pizza') // required option-argument
.option('-c, --cheese [CHEESE]', 'add extra cheese', 'mozzarella') // optional option-argument with default
.option('-t, --tip <VALUE>', 'add tip to purchase cost', parseFloat) // custom parse function
Return an object containing local option values as key-value pairs
Return an object containing merged local and global option values as key-value pairs.
Output help information for this command.
Outputs built-in help, and custom text added using .addHelpText().
Optionalcontext: HelpContextParse argv, setting options and invoking commands when defined.
The default expectation is that the arguments are from node and have the application as argv[0] and the script being run in argv[1], with user parameters after that.
Optionalargv: readonly string[]Optionaloptions: ParseOptionsthis 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.
The default expectation is that the arguments are from node and have the application as argv[0] and the script being run in argv[1], with user parameters after that.
Optionalargv: readonly string[]Optionaloptions: ParseOptionsPromise
Parse options from argv removing known options,
and return argv split into operands and unknown arguments.
argv => operands, unknown
--known kkk op => [op], []
op --known kkk => [op], []
sub --unknown uuu op => [sub], [--unknown uuu op]
sub -- --unknown uuu op => [sub --unknown uuu op], []
Pass through options that come after command-arguments rather than treat them as command-options, so actual command-options come before command-arguments. Turning this on for a subcommand requires positional options to have been enabled on the program (parent commands).
The default behaviour is non-positional and options may appear before or after command-arguments.
OptionalpassThrough: booleanthis 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 contains the short and/or long flags, separated by comma, a pipe or space.
Optionaldescription: stringOptionaldefaultValue: string | boolean | string[]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 contains the short and/or long flags, separated by comma, a pipe or space.
Store option value.
Store option value and where the value came from.
Display the help or a custom message after an error occurs.
OptionaldisplayHelp: string | booleanDisplay suggestion of similar commands for unknown commands, or options for unknown options.
OptionaldisplaySuggestion: booleanWhether 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().
this command for chaining
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().
this command for chaining
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().
OptionalstoreAsProperties: booleanthis command for chaining
Set the summary. Used when listed as subcommand of parent.
this command for chaining
Get the summary.
Set the command usage.
this 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.
Optionalflags: stringOptionaldescription: stringGet the program version.
Custom Commander subclass to wrap Command functionality inside @quatrain/cli.