Class: Mysqlknife::Command

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

Instance Method Summary collapse

Constructor Details

#initializeCommand

Returns a new instance of Command.



5
6
7
8
9
# File 'lib/mysqlknife/command.rb', line 5

def initialize
  @config = Configs.instance
  @ssh    = SSH.new
  @iterm  = Iterm.new
end

Instance Method Details

#execute(cmd) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/mysqlknife/command.rb', line 11

def execute(cmd)
  return false if cmd.nil?

  @iterm.color(@config.color)
  @iterm.name(@config.name)

  if @config.ssh[:use]
    cmd = @ssh.execute(cmd)
  end

  Mysqlknife::Log.new.command(cmd)
  system(cmd)
ensure
  @iterm.name
  @iterm.reset
end