Module: Hackmac::Utils
- Includes:
- FileUtils
- Defined in:
- lib/hackmac/utils.rb
Instance Method Summary collapse
Instance Method Details
#ask(prompt) ⇒ Object
31 32 33 34 |
# File 'lib/hackmac/utils.rb', line 31 def ask(prompt) print prompt.bold.yellow gets =~ /\Ay/i end |
#x(cmd, verbose: true) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/hackmac/utils.rb', line 14 def x(cmd, verbose: true) prompt = cmd =~ /\A\s*sudo/ ? ?# : ?$ output = `#{cmd}` if $?.success? print "#{prompt} #{cmd}".green puts verbose ? "" : " >/dev/null".yellow else print "#{prompt} #{cmd}".red puts verbose ? "" : " >/dev/null".yellow STDERR.puts "command #{cmd.inspect} failed with exit status #{$?.exitstatus}".on_red.white end if verbose print output.italic end output end |