class RHC::Commands::Ssh

Public Instance Methods

run(_, command) click to toggle source
# File lib/rhc/commands/ssh.rb, line 27
def run(_, command)
  raise ArgumentError, "--gears requires a command" if options.gears && command.blank?
  raise ArgumentError, "--limit must be an integer greater than zero" if options.limit && options.limit < 1

  ssh = check_ssh_executable! options.ssh

  if options.gears
    run_on_gears(command.join(' '), find_app(:with_gear_groups => true))
    0
  else
    rest_app = find_app
    $stderr.puts "Connecting to #{rest_app.ssh_string.to_s} ..." unless command.present?

    debug "Using user specified SSH: #{options.ssh}" if options.ssh

    command_line = [RHC::Helpers.split_path(ssh), ('-vvv' if debug?), rest_app.ssh_string.to_s, command].flatten.compact

    debug "Invoking Kernel.exec with #{command_line.inspect}"
    Kernel.send(:exec, *command_line)
  end
end