Rush StackShopBlogEvents
Skip to main content

Home > @rushstack/ts-command-line

ts-command-line package

An object-oriented command-line parser for TypeScript projects.

Classes

ClassDescription
AliasCommandLineAction

Represents a sub-command that is part of the CommandLineParser command line. The sub-command is an alias for another existing action.

The alias name should be comprised of lower case words separated by hyphens or colons. The name should include an English verb (e.g. "deploy"). Use a hyphen to separate words (e.g. "upload-docs").

CommandLineChoiceListParameterThe data type returned by CommandLineParameterProvider.defineChoiceListParameter().
CommandLineChoiceParameterThe data type returned by CommandLineParameterProvider.defineChoiceParameter().
CommandLineFlagParameterThe data type returned by CommandLineParameterProvider.defineFlagParameter().
CommandLineHelperHelpers for working with the ts-command-line API.
CommandLineIntegerListParameterThe data type returned by CommandLineParameterProvider.defineIntegerListParameter().
CommandLineIntegerParameterThe data type returned by CommandLineParameterProvider.defineIntegerParameter().
CommandLineRemainderThe data type returned by CommandLineParameterProvider.defineCommandLineRemainder().
CommandLineStringListParameterThe data type returned by CommandLineParameterProvider.defineStringListParameter().
CommandLineStringParameterThe data type returned by CommandLineParameterProvider.defineStringParameter().
DynamicCommandLineAction
DynamicCommandLineParser

Abstract Classes

Abstract ClassDescription
CommandLineAction

Represents a sub-command that is part of the CommandLineParser command line. Applications should create subclasses of CommandLineAction corresponding to each action that they want to expose.

The action name should be comprised of lower case words separated by hyphens or colons. The name should include an English verb (e.g. "deploy"). Use a hyphen to separate words (e.g. "upload-docs"). A group of related commands can be prefixed with a colon (e.g. "docs:generate", "docs:deploy", "docs:serve", etc).

CommandLineParameterThe base class for the various command-line parameter types.
CommandLineParameterProviderThis is the common base class for CommandLineAction and CommandLineParser that provides functionality for defining command-line parameters.
CommandLineParameterWithArgumentThe common base class for parameters types that receive an argument.
CommandLineParserThe "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 abstract 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.
ScopedCommandLineAction

Represents a sub-command that is part of the CommandLineParser command-line. Applications should create subclasses of ScopedCommandLineAction corresponding to each action that they want to expose.

The action name should be comprised of lower case words separated by hyphens or colons. The name should include an English verb (e.g. "deploy"). Use a hyphen to separate words (e.g. "upload-docs"). A group of related commands can be prefixed with a colon (e.g. "docs:generate", "docs:deploy", "docs:serve", etc).

Scoped commands allow for different parameters to be specified for different provided scoping values. For example, the "scoped-action --scope A" command may allow for different scoped arguments to be specified than the "scoped-action --scope B" command.

Scoped arguments are specified after the "--" pseudo-argument. For example, "scoped-action --scope A -- --scopedFoo --scopedBar".

Enumerations

EnumerationDescription
CommandLineConstantsString constants for command line processing.
CommandLineParameterKindIdentifies the kind of a CommandLineParameter.

Interfaces

InterfaceDescription
IAliasCommandLineActionOptionsOptions for the AliasCommandLineAction constructor.
IBaseCommandLineDefinitionFor use with CommandLineParser, this interface represents a generic command-line parameter
IBaseCommandLineDefinitionWithArgumentThe common base interface for parameter types that accept an argument.
ICommandLineActionOptionsOptions for the CommandLineAction constructor.
ICommandLineChoiceDefinitionFor use with CommandLineParameterProvider.defineChoiceParameter(), this interface defines a command line parameter which is constrained to a list of possible options.
ICommandLineChoiceListDefinitionFor use with CommandLineParameterProvider.defineChoiceListParameter(), this interface defines a command line parameter which is constrained to a list of possible options. The parameter can be specified multiple times to build a list.
ICommandLineFlagDefinitionFor use with CommandLineParameterProvider.defineFlagParameter(), this interface defines a command line parameter that is a boolean flag.
ICommandLineIntegerDefinitionFor use with CommandLineParameterProvider.defineIntegerParameter(), this interface defines a command line parameter whose argument is an integer value.
ICommandLineIntegerListDefinitionFor use with CommandLineParameterProvider.defineIntegerListParameter(), this interface defines a command line parameter whose argument is an integer value. The parameter can be specified multiple times to build a list.
ICommandLineParserOptionsOptions for the CommandLineParser constructor.
ICommandLineRemainderDefinitionFor use with CommandLineParameterProvider.defineCommandLineRemainder(), this interface defines a rule that captures any remaining command line arguments after the recognized portion.
ICommandLineStringDefinitionFor use with CommandLineParameterProvider.defineStringParameter(), this interface defines a command line parameter whose argument is a string value.
ICommandLineStringListDefinitionFor use with CommandLineParameterProvider.defineStringListParameter(), this interface defines a command line parameter whose argument is a single text string. The parameter can be specified multiple times to build a list.
IScopedLongNameParseResultThe result containing the parsed paramter long name and scope. Returned when calling CommandLineParameterProvider.parseScopedLongName().