Skip to main content

abstractCommand <O, P, Options>

Hierarchy

  • CommandManager<Options>
    • Command

Implements

Index

Events

readonlyonAfterRegister

onAfterRegister: Event<[string, Commandable<any, any[]>], string> = ...

Called after a command has been registered.

readonlyonBeforeRegister

onBeforeRegister: Event<[string, Commandable<any, any[]>], string> = ...

Called before a command has been registered.

Other

constructor

  • new Command<O, P, Options>(options?: Options): Command<O, P, Options>

exit

Method to exit the current program, with an optional error code.

help

help: boolean = false

Value of --help, -h passed on the command line.

locale

locale: string = 'en'

Value of --locale passed on the command line.

log

log: LoggerFunction

Method to log to the console using a log level.

readonlyoptions

options: Readonly<Required<Options>>

Validated and configured options.

rest

rest: string[] = []

Additional arguments passed after -- on the command line.

unknown

unknown: UnknownOptionMap = {}

Unknown options passed on the command line.

version

version: boolean = false

Value of --version, -v passed on the command line.

staticaliases

aliases: string[] = []

staticallowUnknownOptions

allowUnknownOptions: boolean = false

staticallowVariadicParams

allowVariadicParams: string | boolean = false

staticcategories

categories: Categories = {}

staticcategory

category: string = ''

staticdeprecated

deprecated: boolean = false

staticdescription

description: string = ''

statichidden

hidden: boolean = false

staticoptions

options: OptionConfigMap = globalOptions

staticparams

params: ParamConfigList = []

staticpath

path: string = ''

staticusage

usage: string | string[] = ''

blueprint

  • blueprint(schemas: __module): object
  • Validate options passed to the constructor.

configure

  • configure(options?: Partial<Options> | (options: Required<Options>) => Partial<Options>): Readonly<Required<Options>>
  • Set an options object by merging the new partial and existing options with the defined blueprint, while running all validation checks. Freeze and return the options object.

    object.configure({ name: 'Boost' });

    object.configure((prevOptions) => ({
    nestedObject: {
    ...prevOptions.nestedObject,
    some: 'value',
    },
    }));

createHelp

  • createHelp(): Promise<ReactElement<any, string | JSXElementConstructor<any>>>
  • Create a React element based on the Help component.

executeCommand

  • executeCommand(command: string, args: string[], options?: Options): Promise<ExecaReturnValue<string>>
  • Execute a system native command with the given arguments and pass the results through a promise. This does not execute Boost CLI commands, use runProgram() instead.

getArguments

  • Return the current command class as an arguments object. Options and params must be parsed first to operate correctly.

getCommand

  • getCommand<O, P>(path: string): null | Commandable<O, P>
  • Return a command by registered path, or null if not found.


    Type parameters

getCommandPaths

  • getCommandPaths(): string[]
  • Return a list of all registered command paths (including aliases).

getMetadata

  • Validate and return all metadata registered to this command instance.

getParserOptions

  • Return metadata as options for argument parsing.

getPath

  • getPath(): string
  • Return the command path (canonical name on the command line).

register

  • Register a command and its canonical path (must be unique), otherwise an error is thrown.

render

  • render(element: ReactElement<any, string | JSXElementConstructor<any>>): Promise<void>
  • Render a React element with Ink and output to the configured streams.

abstractrun

  • Executed when the command is being ran.

runProgram

  • runProgram(argv: Argv): Promise<number>
  • Run the program within itself, by passing a custom command and argv list.

runTask

  • runTask<A, R>(task: (this: TaskContext<O>, ...args: A) => R, ...args: A): R
  • Run a task (function) with the defined arguments and the current command instance bound to the task's context.


    Type parameters

    • A: unknown[]
    • R