class Protobox::Cli
Attributes
args[R]
Public Class Methods
execute(*args)
click to toggle source
Shortcut
# File lib/protobox/cli.rb, line 11 def self.execute(*args) new(*args).execute end
new(*args)
click to toggle source
# File lib/protobox/cli.rb, line 5 def initialize(*args) #@args = Args.new(args) @args = args end
Public Instance Methods
exec(*args)
click to toggle source
Special-case ‘echo` for Windows
Calls superclass method
# File lib/protobox/cli.rb, line 34 def exec *args if args.first == 'echo' && Util::Context.windows? puts args[1..-1].join(' ') else super end end
execute()
click to toggle source
# File lib/protobox/cli.rb, line 15 def execute Commands.run(@args) end
execute_command_chain(commands)
click to toggle source
Runs multiple commands in succession; exits at first failure.
# File lib/protobox/cli.rb, line 20 def execute_command_chain commands commands.each_with_index do |cmd, i| if cmd.respond_to?(:call) then cmd.call elsif i == commands.length - 1 # last command in chain STDOUT.flush; STDERR.flush exec(*cmd) else exit($?.exitstatus) unless system(*cmd) end end end