injekt/slop — Issue #55: --foo=bar syntax consuming following argument
Author: jorgenpt
Created: 2012-01-31 00:50:21+00:00
State: open

Here are two samples of using `on :do_thing=` syntax, and having it consume the next argument. It's both removed from the passed in args (in parse!) mode, and ignored in terms of parsing (so if it's an option, it's not seen).

1.9.2p290 :001 > require 'slop'; args = ["--do_thing=fourtytwo", "hey dawg"]
=> ["--do_thing=fourtytwo", "hey dawg"]
1.9.2p290 :002 > opts = Slop.parse!(args) do on :do_thing=; end
=> #false, :help=>false, :banner=>nil, :ignore_case=>false, :autocreate=>false, :arguments=>false, :optional_arguments=>false, :multiple_switches=>true, :longest_flag=>8} ["#true, :optional_argument=>false, :tail=>false, :default=>nil, :callback=>nil, :delimiter=>\",\", :limit=>0, :match=>nil, :optional=>true, :required=>false, :as=>String, :autocreated=>false}"]>
1.9.2p290 :003 > args
=> []
1.9.2p290 :004 > opts[:do_thing]
=> "fourtytwo"

1.9.2p290 :001 > require 'slop'; args = ["--do_thing=fourtytwo", "--yes"]
=> ["--do_thing=fourtytwo", "--yes"]
1.9.2p290 :002 > opts = Slop.parse!(args) do on :do_thing=; on :yes; end
=> #false, :help=>false, :banner=>nil, :ignore_case=>false, :autocreate=>false, :arguments=>false, :optional_arguments=>false, :multiple_switches=>true, :longest_flag=>8} ["#true, :optional_argument=>false, :tail=>false, :default=>nil, :callback=>nil, :delimiter=>\",\", :limit=>0, :match=>nil, :optional=>true, :required=>false, :as=>String, :autocreated=>false}", "#false, :optional_argument=>false, :tail=>false, :default=>nil, :callback=>nil, :delimiter=>\",\", :limit=>0, :match=>nil, :optional=>true, :required=>false, :as=>String, :autocreated=>false}"]>
1.9.2p290 :003 > opts.yes?
=> false
1.9.2p290 :004 > opts[:do_thing]
=> "fourtytwo"