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

CommandLineAction class

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


export declare abstract class CommandLineAction extends CommandLineParameterProvider 

Extends: CommandLineParameterProvider


Constructor Modifiers Description
(constructor)(options)   Constructs a new instance of the CommandLineAction class


Property Modifiers Type Description
actionName   string 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”
documentation   string 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”.
summary   string A quick summary that is shown on the main help page, which is displayed by the command “example –help”


Method Modifiers Description
onDefineParameters()   The child class should implement this hook to define its command-line parameters, e.g. by calling defineFlagParameter().
onExecute()   Your subclass should implement this hook to perform the operation.