Class: William::Commands

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

Instance Method Summary collapse

Constructor Details

#initialize(host, debug = false) ⇒ Commands

Returns a new instance of Commands.



4
5
6
7
8
9
10
# File 'lib/william/commands.rb', line 4

def initialize(host, debug=false)
  @debug = debug
  @host = host
  @current_command = nil
  @current_command_type = nil
  @start_pwd = @current_pwd = _get_pwd
end

Instance Method Details

#cd(directory) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/william/commands.rb', line 22

def cd(directory)
  command = "cd #{directory}"

  @command_argument = directory
  _show_executing_command(@host, :cd, @command_argument)

  @current_pwd = directory
  yield if block_given?
  @current_pwd = @start_pwd
end

#local(command) ⇒ Object



12
13
14
15
# File 'lib/william/commands.rb', line 12

def local(command)
  @command_argument = command
  _output(:localhost, :local, "#{command}")
end

#run(command) ⇒ Object



17
18
19
20
# File 'lib/william/commands.rb', line 17

def run(command)
  @command_argument = command
  _output(@host, :run, "ssh #{@host} 'cd #{@current_pwd} && #{command}'")
end