GithubHelp home page GithubHelp logo

Comments (9)

leejarvis avatar leejarvis commented on June 6, 2024

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.

leejarvis avatar leejarvis commented on June 6, 2024

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.

ConradIrwin avatar ConradIrwin commented on June 6, 2024

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.

leejarvis avatar leejarvis commented on June 6, 2024

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.

leejarvis avatar leejarvis commented on June 6, 2024

@ConradIrwin Could you confirm your issues are resolved before I push a new gem? Thanks again for reporting.

from slop.

ConradIrwin avatar ConradIrwin commented on June 6, 2024

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.

leejarvis avatar leejarvis commented on June 6, 2024

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.

ConradIrwin avatar ConradIrwin commented on June 6, 2024

Thanks. All our tests pass again now :).

from slop.

leejarvis avatar leejarvis commented on June 6, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.