class CC::CLI::Runner
Public Class Methods
new(args)
click to toggle source
# File lib/cc/cli/runner.rb, line 16 def initialize(args) @args = args end
run(argv)
click to toggle source
# File lib/cc/cli/runner.rb, line 8 def self.run(argv) new(argv).run rescue => ex $stderr.puts("error: (#{ex.class}) #{ex.message}") CLI.logger.debug("backtrace: #{ex.backtrace.join("\n\t")}") exit 1 end
Public Instance Methods
command()
click to toggle source
# File lib/cc/cli/runner.rb, line 51 def command command_name = @args.first case command_name when nil, "-h", "-?", "--help" "help" when "-v", "--version" "version" else command_name end end
command_arguments()
click to toggle source
# File lib/cc/cli/runner.rb, line 47 def command_arguments Array(@args[1..-1]) end
command_class()
click to toggle source
# File lib/cc/cli/runner.rb, line 36 def command_class command_const = Command[command] if command_const.abstract? nil else command_const end rescue NameError nil end
command_not_found()
click to toggle source
# File lib/cc/cli/runner.rb, line 31 def command_not_found $stderr.puts "unknown command #{command}" exit 1 end
run()
click to toggle source
# File lib/cc/cli/runner.rb, line 20 def run VersionChecker.new.check if check_version? if command_class command = command_class.new(command_arguments) command.execute else command_not_found end end
Private Instance Methods
check_version?()
click to toggle source
# File lib/cc/cli/runner.rb, line 65 def check_version? if ARGV.first == "--no-check-version" ARGV.shift false else true end end