module Command
Public Instance Methods
array_message(arr)
click to toggle source
# File lib/command.rb, line 38 def array_message(arr) case arr[0] when :wrong_args msg = symbol_message arr[0] msg += "\n" msg += ' valore possibile: ' values = '[ ' + arr[1].join(' | ').yellow + ' ]' msg += values msg end end
execute_command(cmd)
click to toggle source
executes command and returns properly colored output
# File lib/command.rb, line 51 def execute_command(cmd) output "Executing #{cmd}".yellow res = `#{cmd}` color = $CHILD_STATUS.exitstatus.zero? ? 'green' : 'red' output res.send color stop_if (color == 'red'), 'Error'.red end
output(msg)
click to toggle source
# File lib/command.rb, line 6 def output(msg) puts 'twig binaries > '.black + msg end
stop_if(check, msg, command = '')
click to toggle source
# File lib/command.rb, line 10 def stop_if(check, msg, command = '') if check output_msg = case msg when Symbol symbol_message msg when Array array_message msg else msg end command.empty? || exec(command) puts 'there was a problem > '.red + output_msg exit(1) end end
symbol_message(s)
click to toggle source
# File lib/command.rb, line 27 def symbol_message(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