Class: Kitchen::Command::Base

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/kitchen/command.rb

Overview

Base class for CLI commands.

Author:

Direct Known Subclasses

Action, Console, Diagnose, Doctor, Exec, List, Login, Package, Sink, Test

Instance Method Summary collapse

Methods included from Logging

#banner, #debug, #error, #fatal, #info, #warn

Constructor Details

#initialize(cmd_args, cmd_options, options = {}) ⇒ Base

Contstructs a new Command object.

Parameters:

  • cmd_args (Array)

    remainder of the arguments from processed ARGV

  • cmd_options (Hash)

    hash of Thor options

  • options (Hash) (defaults to: {})

    configuration options

Options Hash (options):

  • :action (String)

    action to take, usually corresponding to the subcommand name (default: ‘nil`)

  • :help (proc)

    a callable that displays help for the command

  • :config (Config)

    a Config object (default: ‘nil`)

  • :loader (Loader)

    a Loader object (default: ‘nil`)

  • :shell (String)

    a Thor shell object



40
41
42
43
44
45
46
47
48
# File 'lib/kitchen/command.rb', line 40

def initialize(cmd_args, cmd_options, options = {})
  @args = cmd_args
  @options = cmd_options
  @action = options.fetch(:action, nil)
  @help = options.fetch(:help, -> { "No help provided" })
  @config = options.fetch(:config, nil)
  @loader = options.fetch(:loader, nil)
  @shell = options.fetch(:shell)
end