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_banner() click to toggle source
print_commands() click to toggle source
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