Exception: VerboseShell::ShellError

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/verbose-shell.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output, cmd, exit_code) ⇒ ShellError

Returns a new instance of ShellError.



18
19
20
21
22
# File 'lib/verbose-shell.rb', line 18

def initialize(output, cmd, exit_code)
  @output = output
  @cmd = cmd
  @exit_code = exit_code
end

Instance Attribute Details

#cmdObject

Returns the value of attribute cmd.



17
18
19
# File 'lib/verbose-shell.rb', line 17

def cmd
  @cmd
end

#exit_codeObject

Returns the value of attribute exit_code.



17
18
19
# File 'lib/verbose-shell.rb', line 17

def exit_code
  @exit_code
end

#outputObject

Returns the value of attribute output.



17
18
19
# File 'lib/verbose-shell.rb', line 17

def output
  @output
end

Instance Method Details

#messageObject



24
25
26
# File 'lib/verbose-shell.rb', line 24

def message
  "\n\n"+(['']*20+@output.split("\n"))[-20..-1].join("\n").lstrip + "\n"+Pastel.new.bright_white.on_red("💩  Command \"#{@cmd[0]}\" returned #{@exit_code}")
end

#to_sObject



27
# File 'lib/verbose-shell.rb', line 27

def to_s; message; end