summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorsigurdsvela <sigurdbergsvela@gmail.com>2015-04-06 23:41:57 +0200
committersigurdsvela <sigurdbergsvela@gmail.com>2015-04-06 23:41:57 +0200
commit3c572378fa8dd437bfb323c9cab39f95ed9a5341 (patch)
treef4438d8830548113eb3de5ddeeac8af6f4c2a39c /lib
parentd16fe87263bd7a3d8c86d2314c2db28afaac002e (diff)
downloadslop-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.rb10
-rw-r--r--lib/slop/option.rb2
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)