Skip to main content

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](/pages/ts-command-line.commandlineparameterprovider)


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


actionNamestringThe 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"
documentationstringA detailed description that is shown on the action help page, which is displayed by the command "example build --help", e.g. for actionName="build".
summarystringA quick summary that is shown on the main help page, which is displayed by the command "example --help"


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.