Rush StackShopBlogEvents
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
parametersreadonlyReadonlyArray<CommandLineParameter>Returns a collection of the parameters that were defined for this object.
ScopingParameterGroup

static

readonly

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

Methods

MethodModifiersDescription
onDefineParameters()protectedThe child class should implement this hook to define its command-line parameters, e.g. by calling defineFlagParameter().
onDefineScopedParameters(scopedParameterProvider)

protected

abstract

The 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()?protected(Optional) The 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()

protected

abstract

Your subclass should implement this hook to perform the operation.