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

Class

Description

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").

CommandLineChoiceListParameter

The data type returned by CommandLineParameterProvider.defineChoiceListParameter().

CommandLineChoiceParameter

The data type returned by CommandLineParameterProvider.defineChoiceParameter().

CommandLineFlagParameter

The data type returned by CommandLineParameterProvider.defineFlagParameter().

CommandLineHelper

Helpers for working with the ts-command-line API.

CommandLineIntegerListParameter

The data type returned by CommandLineParameterProvider.defineIntegerListParameter().

CommandLineIntegerParameter

The data type returned by CommandLineParameterProvider.defineIntegerParameter().

CommandLineParser

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.

CommandLineRemainder

The data type returned by CommandLineParameterProvider.defineCommandLineRemainder().

CommandLineStringListParameter

The data type returned by CommandLineParameterProvider.defineStringListParameter().

CommandLineStringParameter

The data type returned by CommandLineParameterProvider.defineStringParameter().

DynamicCommandLineAction

DynamicCommandLineParser

Abstract Classes

Abstract Class

Description

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).

CommandLineParameterBase

The base class for the various command-line parameter types.

CommandLineParameterProvider

This is the common base class for CommandLineAction and CommandLineParser that provides functionality for defining command-line parameters.

CommandLineParameterWithArgument

The common base class for parameters types that receive an argument.

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

Enumeration

Description

CommandLineConstants

String constants for command line processing.

CommandLineParameterKind

Identifies the kind of a CommandLineParameter.

Interfaces

Interface

Description

IAliasCommandLineActionOptions

Options for the AliasCommandLineAction constructor.

IBaseCommandLineDefinition

For use with CommandLineParser, this interface represents a generic command-line parameter

IBaseCommandLineDefinitionWithArgument

The common base interface for parameter types that accept an argument.

ICommandLineActionOptions

Options for the CommandLineAction constructor.

ICommandLineChoiceDefinition

For use with CommandLineParameterProvider.defineChoiceParameter() and CommandLineParameterProvider.defineChoiceParameter(), this interface defines a command line parameter which is constrained to a list of possible options.

ICommandLineChoiceListDefinition

For 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.

ICommandLineFlagDefinition

For use with CommandLineParameterProvider.defineFlagParameter(), this interface defines a command line parameter that is a boolean flag.

ICommandLineIntegerDefinition

For use with CommandLineParameterProvider.defineIntegerParameter(), CommandLineParameterProvider.defineIntegerParameter(), this interface defines a command line parameter whose argument is an integer value.

ICommandLineIntegerListDefinition

For 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.

ICommandLineParserOptions

Options for the CommandLineParser constructor.

ICommandLineRemainderDefinition

For use with CommandLineParameterProvider.defineCommandLineRemainder(), this interface defines a rule that captures any remaining command line arguments after the recognized portion.

ICommandLineStringDefinition

For use with CommandLineParameterProvider.defineStringParameter() and CommandLineParameterProvider.defineStringParameter(), this interface defines a command line parameter whose argument is a string value.

ICommandLineStringListDefinition

For 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.

IRequiredCommandLineChoiceParameter

The data type returned by CommandLineParameterProvider.defineChoiceParameter().

IRequiredCommandLineIntegerParameter

The data type returned by CommandLineParameterProvider.defineIntegerParameter().

IRequiredCommandLineStringParameter

The data type returned by CommandLineParameterProvider.defineStringParameter().

IScopedLongNameParseResult

The result containing the parsed parameter long name and scope. Returned when calling CommandLineParameterProvider.parseScopedLongName().

Type Aliases

Type Alias

Description

CommandLineParameter