Comments (9)
Argument arrays can no longer contain nil values.
I'm not sure I follow this one. Could you provide an example? I don't see how Argument arrays would ever contain nil values.
Ranges can no-longer have negative argument values.
This is an oversight on my part. I'll add it later today.
:as => :count doesn't work anymore.
Added in the above commit. Thanks for reporting, I'll close this issue once these issues are all resolved.
from slop.
I can't reproduce the Range negative argument value issue. See the following code:
opts = Slop.new do
on :c, :case, argument: true, as: Range
end
opts.parse
p opts.to_hash
#=> {:case=>-1..10}
Also see https://github.com/injekt/slop/blob/master/test/option_test.rb#L78
from slop.
Ok, it turns out the range problem only happens when there's an optional argument:
s = Slop.new{ |opt| opt.on :foo, :f, :as => Range, :optional_argument => true }
s.parse! %w"--foo -1"
# => ["-1"]
The nil's happens because of this:
argstring = "amend-line --help"
argstring =~ /^amend-line\s*(!)?/=> 0
as = Regexp.last_match.to_a.drop(1) + Regexp.last_match.post_match.split(" ")
# => [nil, "--help"]
Slop.new{ |opt| opt.help }.parse!(as)
# NoMethodError: undefined method `start_with?' for nil:NilClass
# from /Users/cirwin/.rvm/gems/ruby-1.9.3-p125@pry/gems/slop-3.2.0/lib/slop.rb:418:in `process_item'
Because the previous version of slop just worked in this regard, I don't think we even noticed how disgusting it was. Now I think about it more, it may be possible to avoid doing this at Pry's end; in case you don't want to allow that :).
from slop.
Slop just expects the input Array to include String only values. Ignoring nil values is something I'm prepared to add, though, and have done in the latest commit. Fixing the other issue now
from slop.
@ConradIrwin Could you confirm your issues are resolved before I push a new gem? Thanks again for reporting.
from slop.
Hi @injekt, thanks for the phenomenal response!
The only remaining issue is the one I alluded to above about the counting being broken:
Slop.new{ |opt| opt.on :v, :verbose, :as => :count }.tap{ |o| o.parse!(%w(-vvv))}.to_hash
# => {:verbose=>1}
from slop.
Hi @ConradIrwin,
You're welcome. Please check the latest commit and run Pry against Slop HEAD to ensure there's no more regression. Once you're happy let me know and I'll push a gem up.
from slop.
Thanks. All our tests pass again now :).
from slop.
Great. I've bumped the version to 3.3.0 to make it a little easier for Pry to manage http://rubygems.org/gems/slop/versions/3.3.0
from slop.
Related Issues (20)
- Thor comparison HOT 1
- ArgumentError not raised when Array arg is missing HOT 1
- Maybe support a choice option by default HOT 2
- Setting an option doesn't set it "everywhere" HOT 2
- Support for command in v4 HOT 1
- `help: false` throws off separator position HOT 4
- Attempt to modify frozen string litterals HOT 2
- Practical example HOT 5
- CI: Switch away from TravisCI HOT 6
- Conditional 'required' option HOT 2
- Custom message with Slop::MissingRequiredOption
- Ruby v3.0.0 problem with Slop v4.8.2 HOT 2
- Some bugs. HOT 1
- Enable frozen strings in Slop using the `# frozen_string_literal: true` pragma HOT 1
- No way to pass in a blank array? HOT 7
- [question] is there a way to check that one or more of some set of args exist? HOT 2
- Default value for boolean flags not working when invoking method HOT 1
- Issue / breaking change with boolean flags with 4.10.0 HOT 2
- Confusing that there's a 4.0 branch... HOT 1
- Bool options bug! HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slop.