1
0
Fork 0
mirror of https://github.com/nishiki/botish.git synced 2024-11-23 00:07:51 +00:00

check if option config file is set

This commit is contained in:
Adrien Waksberg 2017-04-20 22:42:18 +02:00
parent 2bb2525331
commit ff48d7ecf6

View file

@ -24,18 +24,21 @@ require 'botish/botish'
options = {} options = {}
OptionParser.new do |opts| OptionParser.new do |opts|
opts.banner = 'Usage: botish --host irc.freenode.net --channel "test" [options]' opts.banner = 'Usage: botish --config config.yml'
opts.on('-c', '--config PATH') do |path| opts.on('-c', '--config PATH', 'Specify the config file') do |path|
options[:config_file] = path options[:config_file] = path
end end
opts.on('-h', '--help') do opts.on('-h', '--help', 'Show this message') do
puts opts puts opts
exit 0 exit 0
end end
end.parse! end.parse!
raise 'Config file option is missing!' unless options.key?(:config_file)
raise 'The config file doesn\'t exist' unless File.exist?(options[:config_file])
botish = Botish::Botish.new(options[:config_file]) botish = Botish::Botish.new(options[:config_file])
botish.connect botish.connect
botish.listen botish.listen