diff options
Diffstat (limited to 'lib/slop/parser.rb')
-rw-r--r-- | lib/slop/parser.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/slop/parser.rb b/lib/slop/parser.rb index 553c2ff..ea1869e 100644 --- a/lib/slop/parser.rb +++ b/lib/slop/parser.rb @@ -53,6 +53,7 @@ module Slop end # support `foo=bar` + orig_flag = flag.dup if flag.include?("=") flag, arg = flag.split("=") end @@ -60,13 +61,15 @@ module Slop if opt = try_process(flag, arg) # since the option was parsed, we remove it from our # arguments (plus the arg if necessary) - # delete argument first so that it doesn't mess up the index + # delete argument first while we can find its index. if opt.expects_argument? arguments.each_with_index do |argument, i| - arguments.delete_at(i + 1) if argument == flag + if argument == orig_flag && !orig_flag.include?("=") + arguments.delete_at(i + 1) + end end end - arguments.delete(flag) + arguments.delete(orig_flag) end end |