-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No way to pass in a blank array? #266
Comments
Using this code, I can pass in |
I'm an idiot. I was trying to do |
Actually, I would expect your example to work the same way as without the opts = Slop.parse do |o|
o.string "-s", "--str"
o.array "-a", "--arr", default: ["default"]
end
p opts.to_h
But with the
This will need to be looked into. |
Actually, it doesn't work for blank strings either: ruby example.rb --str=""
Traceback (most recent call last):
7: from example.rb:6:in `<main>'
6: from /Users/lee/code/slop/lib/slop.rb:23:in `parse'
5: from /Users/lee/code/slop/lib/slop/options.rb:72:in `parse'
4: from /Users/lee/code/slop/lib/slop/parser.rb:49:in `parse'
3: from /Users/lee/code/slop/lib/slop/parser.rb:49:in `each_with_index'
2: from /Users/lee/code/slop/lib/slop/parser.rb:49:in `each'
1: from /Users/lee/code/slop/lib/slop/parser.rb:60:in `block in parse'
/Users/lee/code/slop/lib/slop/parser.rb:132:in `try_process': unknown option `--str=' (Slop::UnknownOption) So there's clearly a problem when parsing an array of options that includes an argument with an empty string when using the |
Yay! I'm not a total buffoon! |
This is especially useful when your default option value is a non-blank value and you want users to be able to overwrite it with a blank value Closes #266
@jrimmer-housecallpro Could you check your code against #268 and let me know how it goes? |
Works like a charm. Thanks, @leejarvis ! |
If I have an array option with a default, e.g.
While I can certainly replace the default array elements, I can't replace it with an empty array.
The text was updated successfully, but these errors were encountered: