diff options
-rw-r--r-- | lib/longboat/config.rb | 18 | ||||
-rw-r--r-- | lib/longboat/raiders.rb | 4 |
2 files changed, 20 insertions, 2 deletions
diff --git a/lib/longboat/config.rb b/lib/longboat/config.rb index f235154..3a54e92 100644 --- a/lib/longboat/config.rb +++ b/lib/longboat/config.rb @@ -3,7 +3,7 @@ require 'optimist' module Longboat module Config def self.parse! - Optimist::options do + parser = Optimist::Parser.new do # Collection interval opt :raid_every, "Collection interval", type: Integer, default: 60 @@ -18,6 +18,22 @@ module Longboat # Testing opt :test, "Output metrics to stdout and quit", type: TrueClass, default: false end + parser.ignore_invalid_options = true + + begin + parser.parse + rescue Optimist::HelpNeeded + parser.educate + exit + rescue Optimist::VersionNeeded + exit + end + end + + def self.for_raider(&block) + parser = Optimist::Parser.new(&block) + parser.ignore_invalid_options = true + parser.parse end end end diff --git a/lib/longboat/raiders.rb b/lib/longboat/raiders.rb index cd93858..f907f01 100644 --- a/lib/longboat/raiders.rb +++ b/lib/longboat/raiders.rb @@ -15,7 +15,9 @@ module Longboat cname = reqname.split('_').map(&:capitalize).join require "#{dir}/#{reqname}" - @raiders[reqname] = Kernel.const_get(cname).new(@collector, raider_config) + raider = Kernel.const_get(cname).new(@collector, raider_config) + raider.configure! if raider.respond_to?(:configure!) + @raiders[reqname] = raider end end end |