Home > @rushstack/ts-command-line > CommandLineParser
CommandLineParser class
The "argparse" library is a relatively advanced command-line parser with features such as word-wrapping and intelligible error messages (that are lacking in other similar libraries such as commander, yargs, and nomnom). Unfortunately, its ruby-inspired API is awkward to use. The base classes CommandLineParser and CommandLineAction provide a wrapper for "argparse" that makes defining and consuming arguments quick and simple, and enforces that appropriate documentation is provided for each parameter.
Signature:
export declare class CommandLineParser extends CommandLineParameterProvider
Extends: CommandLineParameterProvider
Constructors
Constructor | Modifiers | Description |
|---|---|---|
Constructs a new instance of the |
Properties
Property | Modifiers | Type | Description |
|---|---|---|---|
| ReadonlyArray<CommandLineAction> | Returns the list of actions that were defined for this CommandLineParser object. | |
CommandLineAction | undefined | Reports which CommandLineAction was specified on the command line. |
Methods
Method | Modifiers | Description |
|---|---|---|
Defines a new action that can be used with the CommandLineParser instance. | ||
The program entry point will call this method to begin parsing command-line arguments and executing the corresponding action. | ||
This is similar to CommandLineParser.executeAsync(), except that execution errors simply cause the promise to reject. It is the caller's responsibility to trap | ||
Retrieves the action with the specified name. If no matching action is found, an exception is thrown. | ||
| This hook allows the subclass to perform additional operations before or after the chosen action is executed. | |
Retrieves the action with the specified name. If no matching action is found, undefined is returned. |