diff options
author | sigurdsvela <sigurdbergsvela@gmail.com> | 2015-04-06 23:41:57 +0200 |
---|---|---|
committer | sigurdsvela <sigurdbergsvela@gmail.com> | 2015-04-06 23:41:57 +0200 |
commit | 3c572378fa8dd437bfb323c9cab39f95ed9a5341 (patch) | |
tree | f4438d8830548113eb3de5ddeeac8af6f4c2a39c /lib | |
parent | d16fe87263bd7a3d8c86d2314c2db28afaac002e (diff) | |
download | slop-3c572378fa8dd437bfb323c9cab39f95ed9a5341.tar.gz |
Implement getFlags in MissingArgument
A function in MissingArgument that returns
and array of all the flags that matches
the option missing an argument
Diffstat (limited to 'lib')
-rw-r--r-- | lib/slop/error.rb | 10 | ||||
-rw-r--r-- | lib/slop/option.rb | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/slop/error.rb b/lib/slop/error.rb index 12be24a..d942bbd 100644 --- a/lib/slop/error.rb +++ b/lib/slop/error.rb @@ -12,6 +12,16 @@ module Slop # executed without one. Suppress with the `suppress_errors` # config option. class MissingArgument < Error + def initialize(msg, argument) + super(msg) + @argument = argument + end + + #Get all the flags that matches + #the option with the missing argument + def getFlags() + return @argument + end end # Raised when an unknown option is parsed. Suppress diff --git a/lib/slop/option.rb b/lib/slop/option.rb index 218dc90..4fd2ae0 100644 --- a/lib/slop/option.rb +++ b/lib/slop/option.rb @@ -48,7 +48,7 @@ module Slop @count += 1 if value.nil? && expects_argument? && !suppress_errors? - raise Slop::MissingArgument, "missing argument for #{flag}" + raise Slop::MissingArgument.new("missing argument for #{flag}", flags) end @value = call(value) |