Sha256: ddba48ac2a9583ef7c1a2d3ad85ee6aacb34a9aa9263ef5b94c9c9d335875578
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
require 'logger' require 'gerrit/cli/shell_runner' require 'gerrit/cli/command/clone' require 'gerrit/cli/command/help' require 'gerrit/cli/command/push' require 'gerrit/cli/errors' module Gerrit module Cli end end class Gerrit::Cli::Dispatcher def initialize(logger=nil) @logger = logger || Logger.new(STDOUT) @logger.level = Logger::INFO runner = Gerrit::Cli::ShellRunner.new(logger) @commands = { 'clone' => Gerrit::Cli::Command::Clone.new(logger, runner), 'push' => Gerrit::Cli::Command::Push.new(logger, runner), } @commands['help'] = Gerrit::Cli::Command::Help.new(logger, @commands) end def run_command(argv) if argv.empty? @logger.info("Available Commands:") @logger.info(@commands['help'].commands_summary) else args = argv.dup command_name = args.shift if command = @commands[command_name] command.run(args) else @logger.error("ERROR: Unknown command '#{command_name}'") @commands['help'].show_command_summaries end end rescue Gerrit::Cli::UsageError => ue @logger.error("ERROR: #{ue}\n") command.show_usage exit 1 rescue => e @logger.error("ERROR: #{e}") @logger.debug(e.backtrace.join("\n")) if e.backtrace exit 1 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gerrit-cli-0.0.1 | lib/gerrit/cli/dispatcher.rb |