import CLISubCommand from 'projext/src/abstracts/cliSubCommand.js'
CLISubCommand
Direct Subclass:
A helper class for creating sub commands for the CLI. A sub command works like a CLICommand inside a regular CLICommand.
Constructor Summary
Public Constructor | ||
public abstract |
Class constructor. |
Member Summary
Public Members | ||
public |
A short description for what the generator does. |
|
public |
The name of the sub command for the help interface. |
|
public |
A list with the name of the options the generator supports. |
|
public |
A dictionary of options settings by their option name. |
Method Summary
Public Methods | ||
public |
Add a new option for the command. |
|
public |
Generates a complete description of the sub command and its options in order to be used on the help interface of the CLICommand that implements it. |
|
public abstract |
handle() The method called by the CLICommand that implements the sub command. |
Public Constructors
Public Members
Public Methods
public addOption(name: string, instruction: string, description: string, defaultValue: string) source
Add a new option for the command.
Params:
Name | Type | Attribute | Description |
name | string | The option name. |
|
instruction | string | The option instruction, for example: |
|
description | string |
|
The option description. |
defaultValue | string |
|
The option default value, in case is not used on execution. |
Example:
// To capture an option
this.addOption(
'type',
'-t, --type [type]',
'The type of thingy you want to use?',
);
// As a simple flag
this.addOption(
'ready',
'-r, --ready',
'Is it read?',
false
);
public getHelpInformation(): string source
Generates a complete description of the sub command and its options in order to be used on the help interface of the CLICommand that implements it.
public abstract handle() source
The method called by the CLICommand that implements the sub command. It receives a dicitionary with the parsed options the command received.
Throw:
if not overwritten. |