Options
All
  • Public
  • Public/Protected
  • All
Menu

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) {
    // ...
  }
}

Hierarchy

  • Command

Callable

  • Command(annotations: Command): function
  • 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) {
        // ...
      }
    }

    Parameters

    • annotations: Command

      decorator annotation object

    Returns function

      • (ctor: any): any
      • Parameters

        • ctor: any

        Returns any

Index

Properties

Optional allowUnknown

allowUnknown: boolean

If true, allows any options/flags to pass through the parser. This is useful when command execution is delegated to other APIs.

Optional args

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.

description

description: string

Describes what the command does for help rendering

Optional hidden

hidden: boolean

Command should be hidden

Optional options

options: ICommandOption[]

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$/ }
]