Module: Omnitest::Core::CLI::PerformCommand

Included in:
Omnitest::Core::CLI
Defined in:
lib/omnitest/core/cli.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



9
10
11
# File 'lib/omnitest/core/cli.rb', line 9

def action
  @action
end

Instance Method Details

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

Perform a scenario 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: ‘{}`)



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/omnitest/core/cli.rb', line 20

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

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

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