Module: Command
- Defined in:
- lib/command.rb
Instance Method Summary collapse
- #array_message(arr) ⇒ Object
- #exec_step(command, output = nil) ⇒ Object
- #output(msg) ⇒ Object
- #stop_if(check, msg) ⇒ Object
- #stop_unless(check, msg) ⇒ Object
- #symbol_message(s) ⇒ Object
Instance Method Details
#array_message(arr) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/command.rb', line 45 def arr case arr[0] when :wrong_args msg = arr[0] msg += "\n" msg += " valore possibile: " values = "[ " + arr[1].join(" | ").yellow + " ]" msg += values msg end end |
#exec_step(command, output = nil) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/command.rb', line 5 def exec_step command, output = nil if output puts output else puts "exec > ".green + "#{command}".yellow end `#{command}` exit($?.exitstatus) unless 0 === $?.exitstatus end |
#output(msg) ⇒ Object
15 16 17 |
# File 'lib/command.rb', line 15 def output msg puts "twig binaries > ".black + msg end |
#stop_if(check, msg) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/command.rb', line 19 def stop_if check, msg if check output_msg = case msg when Symbol msg when Array msg else msg end puts "there was a problem > ".red + output_msg exit(1) end end |
#stop_unless(check, msg) ⇒ Object
57 58 59 |
# File 'lib/command.rb', line 57 def stop_unless check, msg stop_if (not check), msg end |
#symbol_message(s) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/command.rb', line 34 def s case s when :clean "hai dei file non committati...non posso continuare'" when :detached_head "repo in stato 'head detached'" when :wrong_args "argomento non corretto" end end |