Module: Kitchen::CLI::PerformCommand

Included in:
Kitchen::CLI, Driver
Defined in:
lib/kitchen/cli.rb

Overview

Common module to load and invoke a CLI-implementation agnostic command.

Instance Method Summary collapse

Instance Method Details

#perform(task, command, args = nil, additional_options = {}) ⇒ Object

Perform a CLI subcommand.

Parameters:

  • task (String)

    action to take, usually corresponding to the subcommand name

  • command (String)

    command class to create and invoke]

  • args (Array) (defaults to: nil)

    remainder arguments from processed ARGV (default: nil)

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

    additional configuration needed to set up the command class (default: {})



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/kitchen/cli.rb', line 44

def perform(task, command, args = nil, additional_options = {})
  require "kitchen/command/#{command}"

  command_options = {
    :action => task,
    :help => -> { help(task) },
    :config => @config,
    :shell => shell
  }.merge(additional_options)

  str_const = Thor::Util.camel_case(command)
  klass = ::Kitchen::Command.const_get(str_const)
  klass.new(args, options, command_options).call
end