lib/ggem/cli.rb in ggem-1.9.5 vs lib/ggem/cli.rb in ggem-1.10.0

- old
+ new

@@ -3,10 +3,11 @@ require "ggem/version" require "ggem/cli/clirb" require "ggem/cli/commands" module GGem; end + class GGem::CLI COMMANDS = CommandSet.new{ |unknown| InvalidCommand.new(unknown) }.tap do |c| c.add(GenerateCommand, "generate", "g") c.add(BuildCommand, "build", "b") c.add(InstallCommand, "install", "i") @@ -14,11 +15,11 @@ c.add(TagCommand, "tag", "t") c.add(ReleaseCommand, "release", "r") end def self.run(args) - self.new.run(args) + new.run(args) end def initialize(kernel = nil, stdout = nil, stderr = nil) @kernel = kernel || Kernel @stdout = stdout || $stdout @@ -32,19 +33,19 @@ cmd.run(args) rescue CLIRB::HelpExit @stdout.puts cmd.help rescue CLIRB::VersionExit @stdout.puts GGem::VERSION - rescue CLIRB::Error, ArgumentError, InvalidCommandError => exception - display_debug(exception) - @stderr.puts "#{exception.message}\n\n" + 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 StandardError => exception - @stderr.puts "#{exception.class}: #{exception.message}" - @stderr.puts exception.backtrace.join("\n") + rescue => ex + @stderr.puts "#{ex.class}: #{ex.message}" + @stderr.puts ex.backtrace.join("\n") @kernel.exit 1 end @kernel.exit 0 end