module Kitchen::CLI::PerformCommand

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

Public Instance Methods

perform(task, command, args = nil, additional_options = {}) click to toggle source

Perform a CLI subcommand.

@param task [String] action to take, usually corresponding to the

subcommand name

@param command [String] command class to create and invoke] @param args [Array] remainder arguments from processed ARGV

(default: `nil`)

@param additional_options [Hash] additional configuration needed to

set up the command class (default: `{}`)
# File lib/kitchen/cli.rb, line 40
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