Home > @rushstack/ts-command-line > CommandLineParameterProvider
CommandLineParameterProvider class
This is the common base class for CommandLineAction and CommandLineParser that provides functionality for defining command-line parameters.
Signature:
export declare abstract class CommandLineParameterProvider
Remarks
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the CommandLineParameterProvider
class.
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
parameters | readonly | ReadonlyArray<CommandLineParameter> | Returns a collection of the parameters that were defined for this object. |
parametersProcessed | readonly | boolean | Informs the caller if the argparse data has been processed into parameters. |
remainder | readonly | CommandLineRemainder | undefined | If CommandLineParameterProvider.defineCommandLineRemainder() was called, this object captures any remaining command line arguments after the recognized portion. |
Methods
Method | Modifiers | Description |
---|---|---|
defineChoiceListParameter(definition) | Defines a command-line parameter whose value must be a string from a fixed set of allowable choices (similar to an enum). The parameter can be specified multiple times to build a list. | |
defineChoiceParameter(definition) | Defines a command-line parameter whose value must be a string from a fixed set of allowable choices (similar to an enum). | |
defineCommandLineRemainder(definition) | Defines a rule that captures any remaining command line arguments after the recognized portion. | |
defineFlagParameter(definition) | Defines a command-line switch whose boolean value is true if the switch is provided, and false otherwise. | |
defineIntegerListParameter(definition) | Defines a command-line parameter whose argument is an integer. The parameter can be specified multiple times to build a list. | |
defineIntegerParameter(definition) | Defines a command-line parameter whose argument is an integer. | |
defineStringListParameter(definition) | Defines a command-line parameter whose argument is a single text string. The parameter can be specified multiple times to build a list. | |
defineStringParameter(definition) | Defines a command-line parameter whose argument is a single text string. | |
getChoiceListParameter(parameterLongName, parameterScope) | Returns the CommandLineChoiceListParameter with the specified long name. | |
getChoiceParameter(parameterLongName, parameterScope) | Returns the CommandLineChoiceParameter with the specified long name. | |
getFlagParameter(parameterLongName, parameterScope) | Returns the CommandLineFlagParameter with the specified long name. | |
getIntegerListParameter(parameterLongName, parameterScope) | Returns the CommandLineIntegerParameter with the specified long name. | |
getIntegerParameter(parameterLongName, parameterScope) | Returns the CommandLineIntegerParameter with the specified long name. | |
getParameterStringMap() | Returns a object which maps the long name of each parameter in this.parameters to the stringified form of its value. This is useful for logging telemetry, but it is not the proper way of accessing parameters or their values. | |
getStringListParameter(parameterLongName, parameterScope) | Returns the CommandLineStringListParameter with the specified long name. | |
getStringParameter(parameterLongName, parameterScope) | Returns the CommandLineStringParameter with the specified long name. | |
onDefineParameters()? | protected | (Optional) The child class should implement this hook to define its command-line parameters, e.g. by calling defineFlagParameter(). |
parseScopedLongName(scopedLongName) | Returns an object with the parsed scope (if present) and the long name of the parameter. | |
renderHelpText() | Generates the command-line help text. | |
renderUsageText() | Generates the command-line usage text. |