interface ICli

A command-line interface created by the cli function.

Methods

command(command, description, options, handler)

Register a command.

Parameters
Name Type Description

command

string | ReadonlyArray<string>

The command string. Use $0 for default command. Add <arg> for required positional parameter. Add [arg] for optional positional parameter. See yargs Command API documentation for details.

description

string

The command description, the text to show in --help menu.

options

LocalOptions

The options accepted by the command. See yargs API documentation for details.

handler

(args: CliArguments<LocalOptions>) => void

The command handler. It may return a promise. If the promise is rejected, the CLI will exit with the help text and a non-zero code.

Returns

ICli<GlobalOptions>

An instance of ICli for chaining.

Signature
command<LocalOptions extends {
        [key: string]: yargs.Options;
    }>(command: string | ReadonlyArray<string>, description: string, options: LocalOptions, handler: (args: CliArguments<LocalOptions>) => void): ICli<GlobalOptions>;

parse()

Parses the command-line arguments and invoke the registered command handler.

Signature
parse(): void;