summaryrefslogtreecommitdiff
path: root/lib/slop.rb
diff options
context:
space:
mode:
authorLee Jarvis <ljjarvis@gmail.com>2013-07-25 10:32:52 +0100
committerLee Jarvis <ljjarvis@gmail.com>2013-07-25 10:32:52 +0100
commit7cfca3fdca18480e06badc68523ea84e1226f0e8 (patch)
tree6662f06b9e5e5a67ac99ecb35f462dd3eca28388 /lib/slop.rb
parent8c4caa9d5e6fa799087528b60e1acaf37c72de63 (diff)
downloadslop-7cfca3fdca18480e06badc68523ea84e1226f0e8.tar.gz
Ensure unknown options are reported for multiple switches
Before this commit we just skipped an option if it wasn't found, we should instead raise an error. closes #122
Diffstat (limited to 'lib/slop.rb')
-rw-r--r--lib/slop.rb15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/slop.rb b/lib/slop.rb
index 1ecb7e7..b99aab9 100644
--- a/lib/slop.rb
+++ b/lib/slop.rb
@@ -567,13 +567,16 @@ class Slop
execute_option(option, nil, index)
flags = argument.split('')
flags.each do |key|
- next unless opt = fetch_option(key)
- opt.count += 1
- if (opt.expects_argument? || opt.accepts_optional_argument?) &&
- (flags[-1] == opt.key) && (val = items[index+1])
- execute_option(opt, val, index, key)
+ if opt = fetch_option(key)
+ opt.count += 1
+ if (opt.expects_argument? || opt.accepts_optional_argument?) &&
+ (flags[-1] == opt.key) && (val = items[index+1])
+ execute_option(opt, val, index, key)
+ else
+ execute_option(opt, nil, index, key)
+ end
else
- execute_option(opt, nil, index, key)
+ raise InvalidOptionError, "Unknown option -#{key}"
end
end
end