>Command

Command

This class is used to build a command-line interface

Each command is represented by a subclass of this class, which may be nested to create more granular commands.

Following is an overview of the types of commands and what they should do.

Any command type

  • Inherit from the command class under which the command should be nested.
  • Set Command.summary to a brief description of the command.
  • Override Command.options to return the options it handles and their descriptions and prepending them to the results of calling super.
  • Override Command#initialize if it handles any parameters.
  • Override Command#validate! to check if the required parameters the command handles are valid, or call Command#help! in case they’re not.

Abstract command

The following is needed for an abstract command:

  • Set Command.abstract_command to true.
  • Subclass the command.

When the optional Command.description is specified, it will be shown at the top of the command’s help banner.

Normal command

The following is needed for a normal command:

  • Set Command.arguments to the description of the arguments this command handles.
  • Override Command#run to perform the actual work.

When the optional Command.description is specified, it will be shown underneath the usage section of the command’s help banner. Otherwise this defaults to Command.summary.

Inherits from:

Object

Child Name Spaces

CLAide::Command::Banner