Class: Commander::Command

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

Instance Method Summary collapse

Instance Method Details

#ssh_action(&block) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/command.rb', line 2

def ssh_action(&block)
  action do |args, options|
    if $ssh_remote
      say "Connecting to remote host #{$hostname}... " if options.verbose
      Net::SSH.start($hostname, $username, $ssh_options.compact) do |ssh|
        block.call(args, options, ssh)
      end
    else
      block.call(args, options, Net::SSH::Connection::LocalSession.new)
    end
  end
end