Class: Cmd

Inherits:
Object show all
Defined in:
lib/erhu/init.rb

Instance Method Summary collapse

Constructor Details

#initialize(pty: true, uuid: false, color: true, printer: :pretty) ⇒ Cmd

Returns a new instance of Cmd.



94
95
96
# File 'lib/erhu/init.rb', line 94

def initialize(pty: true, uuid: false, color: true, printer: :pretty)
  @cmd = TTY::Command.new(pty: pty, uuid: uuid, color: color, pretty: printer)
end

Instance Method Details

#chdir(path) ⇒ Object



98
99
100
101
# File 'lib/erhu/init.rb', line 98

def chdir(path)
  @chdir = path
  self
end

#run(*args, &block) ⇒ Object



103
104
105
106
107
108
109
110
111
# File 'lib/erhu/init.rb', line 103

def run(*args, &block)
  options = args.last.is_a?(Hash) ? args.pop : {}
  options[:chdir] = options.fetch(:chdir, @chdir)
  args << options
  @cmd.run(*args, &block)
  self
rescue => e
  error! e
end