class BaseCLI
implements CLI

Base implementation of a CLI.

By default the following service providers are added:

NOTE: The ConfigurationServiceProvider will not be added if the required allow-read and allow-write permissions are not granted. It can also be excluded if desired via a constructor argument.

By default the following commands are added:

Constructors

new
BaseCLI(
cliConfig: CLIConfig,
stdoutWritableStream: WritableStream,
stderrWritableStream: WritableStream,
stdoutIsColor: boolean,
stderrIsColor: boolean,
stderrTerminal: Terminal,
styler: Styler,
envVarsEnabled?: boolean,
configEnabled?: boolean,
keyValueServiceEnabled?: boolean,
validateAllCommands?: boolean,
)

Constructor configures the instance with the specified CLI application details and WritableStream instances.

Methods

addCommand(command: Command): void

Add a Command to the CLI's CommandRegistry.

If only one non-modifier Command is added, the CLI will operate as a single command CLI and the provided command will be set as a default command. If more than one command is added, the CLI will operate as a multi-command CLI. In this case the default command will be set to a help command.

addServiceProvider(serviceProvider: ServiceProvider): void

Add a ServiceProvider to the CLI's ServiceProviderRegistry.

This will register the ServiceProvider, add any provided services to the Context and register any provided Command instances.

run(args: ReadonlyArray<string>): Promise<RunResult>

Usage

import BaseCLI from ".";