Skip to content
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

1.2.0 makes multivalued params always required #85

Closed
kke opened this issue Feb 12, 2018 · 3 comments
Closed

1.2.0 makes multivalued params always required #85

kke opened this issue Feb 12, 2018 · 3 comments

Comments

@kke
Copy link
Contributor

kke commented Feb 12, 2018

Setting required: false does not help:

require 'clamp'

Clamp do

  option ['--tag', '-t'], 'TAG', "Description", multivalued: true, required: false

  def execute
    puts tag_list.inspect
  end
end
$ ruby test_command.rb
ERROR: option '--tag' is required

See: 'test_command.rb --help'

Adding default: [] makes it fail with Specifying a :default value with :required doesn't make sense (ArgumentError).

@kke
Copy link
Contributor Author

kke commented Feb 12, 2018

Probably caused by #81

@evgeni
Copy link
Contributor

evgeni commented Feb 12, 2018

git bisect confirms afacbb1 is the first bad commit

commit afacbb1b9e63e3f7fb335218924288024733f43a
Author: Evgeni Golov <evgeni@golov.de>
Date:   Thu Dec 7 16:02:18 2017 +0100

    raise an error when a required, multivalued option is left blank
    
    checking for nil? returns false on an empty Array which is the default
    value for an multivalued option. also check for empty? in that case.

sorry about that

@evgeni
Copy link
Contributor

evgeni commented Feb 12, 2018

#86 should fix this, @kke care to test?

@mdub mdub closed this as completed in edb9a2a Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants