class Kafkat::CLI
Attributes
config[R]
Public Class Methods
run!()
click to toggle source
# File lib/kafkat/cli.rb, line 5 def self.run! new.run end
Public Instance Methods
bad_config_error()
click to toggle source
# File lib/kafkat/cli.rb, line 60 def bad_config_error print "Configuration file failed to parse (~/.kafkatcfg).\n" exit 1 end
load_config()
click to toggle source
# File lib/kafkat/cli.rb, line 14 def load_config @config = Config.load! rescue Config::NotFoundError no_config_error rescue Config::ParseError bad_config_error end
no_command_error()
click to toggle source
# File lib/kafkat/cli.rb, line 65 def no_command_error print "This command isn't recognized.\n" print_commands exit 1 end
no_config_error()
click to toggle source
# File lib/kafkat/cli.rb, line 55 def no_config_error print "Configuration file not found (~/.kafkatcfg). See documentation.\n" exit 1 end
print_commands()
click to toggle source
# File lib/kafkat/cli.rb, line 42 def print_commands print "\nHere's a list of supported commands:\n\n" Command.all.values.sort_by(&:command_name).each do |klass| klass.usages.each do |usage| format, description = usage[0], usage[1] padding_length = 68 - format.length padding = " " * padding_length unless padding_length < 0 print " #{format}#{padding}#{description}\n" end end print "\n" end
run()
click to toggle source
# File lib/kafkat/cli.rb, line 9 def run load_config run_command end
run_command()
click to toggle source
# File lib/kafkat/cli.rb, line 22 def run_command name = ARGV.shift if name command_klass = Command.get(name) command = command_klass.new(config) command.run else print_banner print_commands exit 0 end rescue Command::NotFoundError no_command_error end