diff options
author | Lee Jarvis <ljjarvis@gmail.com> | 2014-11-19 10:06:48 +0000 |
---|---|---|
committer | Lee Jarvis <ljjarvis@gmail.com> | 2014-11-19 10:06:48 +0000 |
commit | 3f4fb888ab522f72bb525769446899ad30ece251 (patch) | |
tree | f1c7a0b36d509772dd28d91313c6befc4abd6f8a /lib/slop/parser.rb | |
parent | 16f277c77577d7f58b7ab424c64df36cf32aee2f (diff) | |
download | slop-3f4fb888ab522f72bb525769446899ad30ece251.tar.gz |
Expose used/unused options in parser
Diffstat (limited to 'lib/slop/parser.rb')
-rw-r--r-- | lib/slop/parser.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/slop/parser.rb b/lib/slop/parser.rb index 3bcb0a9..b6dc83f 100644 --- a/lib/slop/parser.rb +++ b/lib/slop/parser.rb @@ -1,9 +1,10 @@ module Slop class Parser - attr_reader :options + attr_reader :options, :used_options def initialize(options) - @options = options + @options = options + @used_options = [] end def parse(strings) @@ -14,6 +15,8 @@ module Slop option = matching_option(flag) if option + used_options << option + option.call(arg) end end @@ -21,6 +24,10 @@ module Slop Result.new(self) end + def unused_options + options.to_a - used_options + end + private def matching_option(flag) |