Unable to use lists multiple times #71

Closed
simonc opened this Issue Jul 31, 2012 · 5 comments

Comments

Projects
None yet
2 participants
@simonc

simonc commented Jul 31, 2012

Hi,

I'm trying to use lists several times as specified in the wiki. Here are my two trials:

# This one is like the wiki says

opts = Slop.new do
  on :friends, 'Your friends', true, :as => Array
end

opts.parse %w[ --friends lee foo bar --friends john,jack ]

p opts[:friends] #=> true
# This one is with a = sign after :friends

opts = Slop.new do
  on :friends=, 'Your friends', true, :as => Array
end

opts.parse %w[ --friends lee foo bar --friends john,jack ]

p opts[:friends] #=> ["john", "jack"]

In both cases the return value is not the expected one ["lee", "john", "jack"]

@leejarvis

This comment has been minimized.

Show comment Hide comment
@leejarvis

leejarvis Jul 31, 2012

Owner

What version of Slop are you using?

Owner

leejarvis commented Jul 31, 2012

What version of Slop are you using?

@simonc

This comment has been minimized.

Show comment Hide comment
@simonc

simonc Jul 31, 2012

The last one, 3.3.2

simonc commented Jul 31, 2012

The last one, 3.3.2

@simonc

This comment has been minimized.

Show comment Hide comment
@simonc

simonc Jul 31, 2012

I wrote the following test and ran it against the repository code base and it failed:

test "list called twice" do
  opts = Slop.new { on :list=, '', true, as: Array }
  args = %w(--list a --list b,c)
  opts.parse!(args)
  assert_equal %w(a b c), opts[:list]
end

simonc commented Jul 31, 2012

I wrote the following test and ran it against the repository code base and it failed:

test "list called twice" do
  opts = Slop.new { on :list=, '', true, as: Array }
  args = %w(--list a --list b,c)
  opts.parse!(args)
  assert_equal %w(a b c), opts[:list]
end
@leejarvis

This comment has been minimized.

Show comment Hide comment
@leejarvis

leejarvis Jul 31, 2012

Owner

The wiki is pointed at version 2 of Slop. I haven't yet gotten around to updating it. Sorry for the missinformation but the syntax :option, 'Description', true was deprecated in version 3. Version 3 also doesn't append to the same lists, I can add this as a new feature, though. Also the syntax --friends foo bar wont work, they need to be a single argument separated by a delimiter (defaulting to a comma).

Owner

leejarvis commented Jul 31, 2012

The wiki is pointed at version 2 of Slop. I haven't yet gotten around to updating it. Sorry for the missinformation but the syntax :option, 'Description', true was deprecated in version 3. Version 3 also doesn't append to the same lists, I can add this as a new feature, though. Also the syntax --friends foo bar wont work, they need to be a single argument separated by a delimiter (defaulting to a comma).

@simonc

This comment has been minimized.

Show comment Hide comment
@simonc

simonc Jul 31, 2012

Ok, thanks for your rapid answer. I'll use a callback block as workaround for now ;)

simonc commented Jul 31, 2012

Ok, thanks for your rapid answer. I'll use a callback block as workaround for now ;)

@leejarvis leejarvis closed this in ccadb9d Jul 31, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment