Method: Sym::App::KeyChain#execute

Defined in:
lib/sym/app/keychain.rb

#execute(command) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/sym/app/keychain.rb', line 59

def execute(command)
  command += ' 2>/dev/null' if stderr_disabled
  puts "> #{command.yellow}" if opts[:verbose]
  output = `#{command}`
  result = $?
  unless result.success?
    warn "> ERROR running command:\n>   $ #{output.red}" if !stderr_disabled && opts[:verbose]
    raise Sym::Errors::KeyChainCommandError.new("Command error: #{result}, command: #{command}")
  end

  output.chomp
rescue Errno::ENOENT => e
  raise Sym::Errors::KeyChainCommandError.new("Command error: #{e.message}, command: #{command}")
end