Class Cri::CommandDSL
In: lib/cri/command_dsl.rb
Parent: Object

The command DSL is a class that is used for building and modifying commands.

Methods

add_option   aliases   command   description   flag   forbidden   name   new   opt   option   optional   required   run   runner   subcommand   summary   usage  

Public Class methods

@param [Cri::Command, nil] command The command to modify, or nil if a

  new command should be created

Public Instance methods

Sets the command aliases.

@param [String, Symbol, Array] args The new command aliases

@return [void]

@return [Cri::Command] The built command

Sets the command description.

@param [String] arg The new command description

@return [void]

Adds a new option with a forbidden argument to the command. If a block is given, it will be executed when the option is successfully parsed.

@param [String, Symbol] short The short option name

@param [String, Symbol] long The long option name

@param [String] desc The option description

@return [void]

@see {option}

forbidden(short, long, desc, &block)

Alias for flag

Sets the command name.

@param [String] arg The new command name

@return [void]

opt(short, long, desc, params={}, &block)

Alias for option

Adds a new option to the command. If a block is given, it will be executed when the option is successfully parsed.

@param [String, Symbol] short The short option name

@param [String, Symbol] long The long option name

@param [String] desc The option description

@option params [:forbidden, :required, :optional] :argument Whether the

  argument is forbidden, required or optional

@return [void]

Adds a new option with an optional argument to the command. If a block is given, it will be executed when the option is successfully parsed.

@param [String, Symbol] short The short option name

@param [String, Symbol] long The long option name

@param [String] desc The option description

@return [void]

@see {option}

Adds a new option with a required argument to the command. If a block is given, it will be executed when the option is successfully parsed.

@param [String, Symbol] short The short option name

@param [String, Symbol] long The long option name

@param [String] desc The option description

@return [void]

@see {option}

Sets the run block to the given block. The given block should have two or three arguments (options, arguments, and optionally the command). Calling this will override existing run block or runner declarations (using {run} and {runner}, respectively).

@return [void]

Defines the runner class for this command. Calling this will override existing run block or runner declarations (using {run} and {runner}, respectively).

@param [Class<CommandRunner>] klass The command runner class (subclass

  of {CommandRunner}) that is used for executing this command.

@return [void]

Adds a subcommand to the current command. The command can either be given explicitly, or a block can be given that defines the command.

@param [Cri::Command, nil] command The command to add as a subcommand,

  or nil if the block should be used to define the command that will be
  added as a subcommand

@return [void]

Sets the command summary.

@param [String] arg The new command summary

@return [void]

Sets the command usage. The usage should not include the “usage:” prefix, nor should it include the command names of the supercommand.

@param [String] arg The new command usage

@return [void]

Protected Instance methods

[Validate]