class BubBot::CLI
Constants
- DEFAULT_CONFIG_FILENAME
Public Class Methods
new(args)
click to toggle source
# File lib/bub_bot/cli.rb, line 5 def initialize(args) @args = args @filename = args[0] || DEFAULT_CONFIG_FILENAME end
Public Instance Methods
start()
click to toggle source
# File lib/bub_bot/cli.rb, line 11 def start print_usage && return unless check_usage configure_from_file(@filename) BubBot.start end
Private Instance Methods
check_usage()
click to toggle source
# File lib/bub_bot/cli.rb, line 31 def check_usage @args.count <= 1 end
configure_from_file(filename)
click to toggle source
# File lib/bub_bot/cli.rb, line 21 def configure_from_file(filename) file_data = YAML.load_file(filename) BubBot.configure do |config| BubBot::Configuration::OPTIONS.each do |option_name| config.public_send((option_name.to_s + '=').to_sym, file_data[option_name.to_s]) end end end
print_usage()
click to toggle source
# File lib/bub_bot/cli.rb, line 35 def print_usage puts <<USAGE Usage: bub_bot [config_filename] Default to #{DEFAULT_CONFIG_FILENAME} if config_filename is not provided USAGE end