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

required positional arguments and a vector positionals #306

Merged
merged 3 commits into from
Aug 7, 2019

Conversation

phlptp
Copy link
Collaborator

@phlptp phlptp commented Jul 30, 2019

This PR adds a loop on the positional parsing to check for remaining required positionals and prioritizing them if positionals_at_end is activated.

it addresses issue #295

@codecov
Copy link

codecov bot commented Jul 30, 2019

Codecov Report

Merging #306 into master will decrease coverage by 0.06%.
The diff coverage is 91.3%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #306      +/-   ##
==========================================
- Coverage     100%   99.93%   -0.07%     
==========================================
  Files          12       12              
  Lines        2935     2954      +19     
==========================================
+ Hits         2935     2952      +17     
- Misses          0        2       +2
Impacted Files Coverage Δ
include/CLI/App.hpp 99.84% <91.3%> (-0.16%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ba7aac9...e365c78. Read the comment docs.

@codecov
Copy link

codecov bot commented Jul 30, 2019

Codecov Report

Merging #306 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #306   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          12     12           
  Lines        2935   2954   +19     
=====================================
+ Hits         2935   2954   +19
Impacted Files Coverage Δ
include/CLI/App.hpp 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ba7aac9...f11a9f8. Read the comment docs.

Copy link
Collaborator

@henryiii henryiii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me - I was going to suggest adding a test for two ending positionals but you already have one. 👍 @kelvinhammond, @WenbinHou, does this look good to you? The positionals_at_end setting is already there, this just modifies the way it works with an ending positional.

@phlptp
Copy link
Collaborator Author

phlptp commented Jul 30, 2019

I will add that it will ONLY modify current operations if there are required positionals and the positionals_at_end flag is activated.

@henryiii
Copy link
Collaborator

henryiii commented Jul 30, 2019

Do we need the positionals_at_end and required only behavior? Why would you ever want an unlimited positional followed by limited positionals to not match the limited positionals? Otherwise, they would never match.

@phlptp
Copy link
Collaborator Author

phlptp commented Jul 30, 2019

I think the biggest reason was to ensure the behavior worked and reduce potential ambiguities. If you didn't require positionals_at_end you could have regular arguments at the end of the args vector and the option would not trigger.

I think if you removed that, you would add a bit of overhead for regular positionals and might be confusing sometimes why it wouldn't work, but otherwise in the cases tested it should work equivalently. Right now there is a specialized case in which the check occurs, and only a bool check overhead in other cases.

It might be reasonable to expand it further but it might be worth considering clarifying and expanding desired rules for positional argument priority first. This topic also has some relationship with #297.

@WenbinHou
Copy link

So why this PR is not merged till now?

@henryiii
Copy link
Collaborator

henryiii commented Aug 7, 2019

I think we can go ahead and merge now, then address the "worth considering clarifying and expanding desired rules for positional argument priority first" as listed above.

@henryiii henryiii merged commit 4bfce43 into CLIUtils:master Aug 7, 2019
@henryiii henryiii deleted the required_positional_check branch August 7, 2019 20:49
@henryiii henryiii added this to the v1.9 milestone Dec 31, 2019
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

Successfully merging this pull request may close these issues.

3 participants