Command Implementation decorator factory
@Command({
description: 'My super command',
args: [
{ name: 'somearg', optional: true }, // optional argument
],
options: [
{ flag: '-f, --file <name>', description: 'input file'}
]
})
export class MyCommand extends BaseCommand {
public async run(options: {file?: string}, somearg?: string) {
// ...
}
}
decorator annotation object
If true, allows any options/flags to pass through the parser. This is useful when command execution is delegated to other APIs.
Specify arguments expected by the command. All arguments will be passed to
the run method in the order which they are declared. If providing variadic
arguments with multi: true, then this must be the last argument listed.
Describes what the command does for help rendering
Command should be hidden
Define command options (flags) to be parsed. All options will be passed to
the run method as the first argument, where the key is always the "--long"
name declared in the option flag syntax.
Using the fn property as a callback supports accepting multiple values
in a manner like Array.prototype.reduce: (val: any, values: any) => any)
where the first argument is the current value, the second argument is the
aggregated values to that point, and the new object is returned.
options: [
{ flag: '-f, --file <name>', description: 'file name', fn: /\.zip$/ }
]
Annotation metadata for the Command implementation decorator Command Implementation decorator factory
@Command({ description: 'My super command', args: [ { name: 'somearg', optional: true }, // optional argument ], options: [ { flag: '-f, --file <name>', description: 'input file'} ] }) export class MyCommand extends BaseCommand { public async run(options: {file?: string}, somearg?: string) { // ... } }