CLI Namespace
Types and classes exposed under the CLI namespace.
Constants
CLI.ValidEvents
ts
["command"] as constList of valid event names supported by CLI, CLI.Command, and CLI.Command.Option.
Types
CLI.ValidEvent
ts
type CLI.ValidEvent = (typeof CLI.ValidEvents)[number]Union of valid event names. Currently only "command".
Classes
CLI.Command
A command in a CLI.
Constructor
ts
new CLI.Command(name: string, commandcreatorfunction: Function)Creates a new command instance. This constructor is called internally by CLI.command(...).
Properties
| Property | Type | Description |
|---|---|---|
name | string | The command name. |
Methods
.on(event: CLI.ValidEvent, func: ({ commandArgs, options }) => any)
| Argument | Type | Description |
|---|---|---|
event | CLI.ValidEvent | The event name. Currently only "command" is valid. |
func | function | Callback invoked when the event fires. |
Registers a handler for this command.
Event payload:
ts
{
commandArgs: string[];
options: { option: string; arguments: string[] }[];
}.option(name: string)
| Argument | Type | Description |
|---|---|---|
name | string | The option name. |
Creates a new option under this command. Returns a CLI.Command.Option instance.
.command(...args: any[])
Forwards to the parent CLI command(...) creator function.
CLI.Command.Option
An option that belongs to a CLI.Command.
Constructor
ts
new CLI.Command.Option(
name: string,
optioncreatorfunc: Function,
commandcreatorfunction: Function
)Creates a new option instance. This constructor is called internally by Command.option(...).
Properties
| Property | Type | Description |
|---|---|---|
name | string | The option name. |
Methods
.on(event: CLI.ValidEvent, func: ({ commandArgs, options }) => any)
| Argument | Type | Description |
|---|---|---|
event | CLI.ValidEvent | The event name. Currently only "command" is valid. |
func | function | Callback invoked when the event fires. |
Registers a handler for this option.
Event payload:
ts
{
commandArgs: string[];
options: { option: string; arguments: string[] }[];
}.command(...args: any[])
Forwards to the parent CLI command(...) creator function.
.option(...args: any[])
Forwards to the parent command option(...) creator function.