Class: VagrantPlugins::DevCommands::Runner::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant/devcommands/runner/command.rb

Overview

Command runner

Constant Summary collapse

UTIL =
VagrantPlugins::DevCommands::Util

Instance Method Summary collapse

Constructor Details

#initialize(plugin, argv, env, registry) ⇒ Command

Returns a new instance of Command.



10
11
12
13
14
15
# File 'lib/vagrant/devcommands/runner/command.rb', line 10

def initialize(plugin, argv, env, registry)
  @plugin   = plugin
  @argv     = argv
  @env      = env
  @registry = registry
end

Instance Method Details

#run(command) ⇒ Object

rubocop:disable Metrics/MethodLength



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vagrant/devcommands/runner/command.rb', line 18

def run(command)
  argv    = run_argv
  machine = run_machine(command)
  script  = run_script(command, argv)

  return 2 unless script

  @plugin.proxy_with_target_vms(machine, single_target: true) do |vm|
    env = vm.action(:ssh_run,
                    ssh_run_command: script,
                    ssh_opts: { extra_args: ['-q'] },
                    tty: command.tty)

    return env[:ssh_run_exit_status] || 0
  end
end