29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/ggem/cli.rb', line 29
def run(args)
begin
cmd_name = args.shift
cmd = COMMANDS[cmd_name]
cmd.run(args)
rescue CLIRB::HelpExit
@stdout.puts cmd.help
rescue CLIRB::VersionExit
@stdout.puts GGem::VERSION
rescue CLIRB::Error, ArgumentError, InvalidCommandError => ex
display_debug(ex)
@stderr.puts "#{ex.message}\n\n"
@stdout.puts cmd.help
@kernel.exit 1
rescue CommandExitError
@kernel.exit 1
rescue => ex
@stderr.puts "#{ex.class}: #{ex.message}"
@stderr.puts ex.backtrace.join("\n")
@kernel.exit 1
end
@kernel.exit 0
end
|