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
# 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
    else
      say 'Running commands locally... ' if options.verbose
    end
    Net::SSH.with_session(ssh_session_options) { |ssh| block.call(args, options, ssh) }
  end
end