RoadmapShopEvents
Skip to main content

Home > @rushstack/ts-command-line > ScopedCommandLineAction

ScopedCommandLineAction class

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

Signature:

export declare abstract class ScopedCommandLineAction extends CommandLineAction 

Extends: CommandLineAction

Constructors

ConstructorModifiersDescription
(constructor)(options)Constructs a new instance of the ScopedCommandLineAction class

Properties

PropertyModifiersTypeDescription
actionNamereadonlystring

The name of the action. For example, if the tool is called "example", then the "build" action might be invoked as: "example build -q --some-other-option"

(Inherited from CommandLineAction)

documentationreadonlystring

A detailed description that is shown on the action help page, which is displayed by the command "example build --help", e.g. for actionName="build".

(Inherited from CommandLineAction)

parametersreadonlyReadonlyArray<CommandLineParameter>Returns a collection of the parameters that were defined for this object.
parametersProcessedreadonlyboolean

Informs the caller if the argparse data has been processed into parameters.

(Inherited from CommandLineParameterProvider)

remainderreadonlyCommandLineRemainder | undefined

If CommandLineParameterProvider.defineCommandLineRemainder() was called, this object captures any remaining command line arguments after the recognized portion.

(Inherited from CommandLineParameterProvider)

ScopingParameterGroup

readonly

static

typeof SCOPING_PARAMETER_GROUPThe required group name to apply to all scoping parameters. At least one parameter must be defined with this group name.
summaryreadonlystring

A quick summary that is shown on the main help page, which is displayed by the command "example --help"

(Inherited from CommandLineAction)

Methods

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

(Inherited from CommandLineParameterProvider)

defineChoiceParameter(definition)

Defines a command-line parameter whose value must be a string from a fixed set of allowable choices (similar to an enum).

(Inherited from CommandLineParameterProvider)

defineCommandLineRemainder(definition)

Defines a rule that captures any remaining command line arguments after the recognized portion.

(Inherited from CommandLineParameterProvider)

defineFlagParameter(definition)

Defines a command-line switch whose boolean value is true if the switch is provided, and false otherwise.

(Inherited from CommandLineParameterProvider)

defineIntegerListParameter(definition)

Defines a command-line parameter whose argument is an integer. The parameter can be specified multiple times to build a list.

(Inherited from CommandLineParameterProvider)

defineIntegerParameter(definition)

Defines a command-line parameter whose argument is an integer.

(Inherited from CommandLineParameterProvider)

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.

(Inherited from CommandLineParameterProvider)

defineStringParameter(definition)

Defines a command-line parameter whose argument is a single text string.

(Inherited from CommandLineParameterProvider)

getChoiceListParameter(parameterLongName, parameterScope)

Returns the CommandLineChoiceListParameter with the specified long name.

(Inherited from CommandLineParameterProvider)

getChoiceParameter(parameterLongName, parameterScope)

Returns the CommandLineChoiceParameter with the specified long name.

(Inherited from CommandLineParameterProvider)

getFlagParameter(parameterLongName, parameterScope)

Returns the CommandLineFlagParameter with the specified long name.

(Inherited from CommandLineParameterProvider)

getIntegerListParameter(parameterLongName, parameterScope)

Returns the CommandLineIntegerParameter with the specified long name.

(Inherited from CommandLineParameterProvider)

getIntegerParameter(parameterLongName, parameterScope)

Returns the CommandLineIntegerParameter with the specified long name.

(Inherited from CommandLineParameterProvider)

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.

(Inherited from CommandLineParameterProvider)

getStringListParameter(parameterLongName, parameterScope)

Returns the CommandLineStringListParameter with the specified long name.

(Inherited from CommandLineParameterProvider)

getStringParameter(parameterLongName, parameterScope)

Returns the CommandLineStringParameter with the specified long name.

(Inherited from CommandLineParameterProvider)

onDefineParameters()protectedThe child class should implement this hook to define its command-line parameters, e.g. by calling defineFlagParameter().
onDefineScopedParameters(scopedParameterProvider)protectedThe child class should implement this hook to define its scoped command-line parameters, e.g. by calling scopedParameterProvider.defineFlagParameter(). These parameters will only be available if the action is invoked with a scope.
onDefineUnscopedParameters()protectedThe child class should implement this hook to define its unscoped command-line parameters, e.g. by calling defineFlagParameter(). At least one scoping parameter must be defined. Scoping parameters are defined by setting the parameterGroupName to ScopedCommandLineAction.ScopingParameterGroupName.
onExecute()protectedYour subclass should implement this hook to perform the operation.
parseScopedLongName(scopedLongName)

Returns an object with the parsed scope (if present) and the long name of the parameter.

(Inherited from CommandLineParameterProvider)

renderHelpText()

Generates the command-line help text.

(Inherited from CommandLineParameterProvider)

renderUsageText()

Generates the command-line usage text.

(Inherited from CommandLineParameterProvider)