-
Notifications
You must be signed in to change notification settings - Fork 71
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
Fix a bug that flag value is processed as flag #241
Conversation
Thanks @kou -- please could you check the Travis failures and tweak your changes to make the build green? I'll take a closer look afterwards |
5c4cc07
to
7e76b6d
Compare
Oh sorry. I've fixed the failure. We can't use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a couple of comments but happy to merge after those. Thanks for fixing the build!
lib/slop/parser.rb
Outdated
@@ -106,6 +106,13 @@ def unused_options | |||
|
|||
private | |||
|
|||
def consume_next_argument?(flag) | |||
return false if /=/ === flag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use flag.include?
here instead? I think it's more obvious
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Done.
test/parser_test.rb
Outdated
@@ -49,6 +49,12 @@ | |||
assert_equal(-123.987, @result[:multiple]) | |||
end | |||
|
|||
it "parses negative float" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test description isn't right, a c+p I guess?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh... Sorry.
I've fixed the description and move this test under "parses arg with leading -". Because they are related.
7e76b6d
to
9ff7724
Compare
I've pushed fixes by amending the original commit. |
If flag value starts with "-", unknown option error is raised. The current flag value check is "orig_arg == opt.value.to_s". There are some objects such as Regexp and Time that input value and its #to_s aren't same.
9ff7724
to
c026ee9
Compare
The force-push is fine. I'll get this merged. Thanks! |
If flag value starts with "-", unknown option error is raised.
The current flag value check is "orig_arg == opt.value.to_s". There
are some objects such as Regexp and Time that input value and its #to_s
aren't same.