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

Add needs to subcommand #317

Merged
merged 17 commits into from
Oct 25, 2019
Merged

Conversation

phlptp
Copy link
Collaborator

@phlptp phlptp commented Sep 6, 2019

This PR will address #291 and #288

it adds a needs function for subcommands and options to the app as well as a remove needs. it also adds some alias operations to app so multiple subcommand names can represent a single subcommand.

This will also work for nameless subcommands(option_groups) so the same group can be a subcommand or act just like regular options.

@phlptp
Copy link
Collaborator Author

phlptp commented Sep 6, 2019

  • write up readme documentation changes
  • a few tests of different callback ordering and the needs operation in context of argument ordering
  • a little more exploration of the implications of the aliases
  • get full code coverage

@codecov
Copy link

codecov bot commented Sep 6, 2019

Codecov Report

Merging #317 into master will decrease coverage by 0.25%.
The diff coverage is 88.05%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #317      +/-   ##
==========================================
- Coverage     100%   99.74%   -0.26%     
==========================================
  Files          12       12              
  Lines        3038     3091      +53     
==========================================
+ Hits         3038     3083      +45     
- Misses          0        8       +8
Impacted Files Coverage Δ
include/CLI/Option.hpp 100% <100%> (ø) ⬆️
include/CLI/App.hpp 99.37% <86.44%> (-0.63%) ⬇️

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 cf4933d...dbaebf7. Read the comment docs.

@codecov
Copy link

codecov bot commented Sep 6, 2019

Codecov Report

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

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #317    +/-   ##
======================================
  Coverage     100%   100%            
======================================
  Files          12     12            
  Lines        3048   3175   +127     
======================================
+ Hits         3048   3175   +127
Impacted Files Coverage Δ
include/CLI/Option.hpp 100% <100%> (ø) ⬆️
include/CLI/App.hpp 100% <100%> (ø) ⬆️
include/CLI/Error.hpp 100% <0%> (ø) ⬆️

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 c1799d2...a460029. Read the comment docs.

@phlptp phlptp force-pushed the add_needs_to_subcommand branch from 04540db to c854569 Compare September 7, 2019 13:49
@phlptp
Copy link
Collaborator Author

phlptp commented Sep 9, 2019

I have run into a few issues with the interaction of needs and the callback operations and the fallthrough flag. Still working on how to resolve these, but it will probably be a few days before things come together.

@phlptp
Copy link
Collaborator Author

phlptp commented Sep 10, 2019

This PR should also address #284 when finished

@phlptp
Copy link
Collaborator Author

phlptp commented Sep 10, 2019

#272 is also addressed, since the aliases needed to be checked as well

@phlptp
Copy link
Collaborator Author

phlptp commented Sep 10, 2019

In considering Aliases, there is a possibility of conflict with existing subcommands and ignore_case, ignore underscore variants of such. This required somewhat more complicated checking of the subcommand names. But also in exploring it the ignore_case, ignore_underscore, name functions also did not currently check this, which means it was possible to generate conflicts. So these checks were added and those functions were made exception safe. more testing is required

@phlptp
Copy link
Collaborator Author

phlptp commented Sep 13, 2019

@henryiii I have been adding checks to make sure subcommands don't overlap in name or alias.
Previously we were not checking overlap on the option_groups, so multiple option_groups could have the same subcommand name See SameSubcommand The question is do we want to allow this explicitly or not? Basically should we allow the potential for using option_groups to have the same subcommand mean multiple different things if called multiple times.

Options

  1. Disallow the same name to potentially reference multiple subcommands
  2. Allow the same name to reference multiple subcommands through option_groups(this is what is done currently)
  3. Add a flag that explicitly allows 2 if set to true.

@phlptp
Copy link
Collaborator Author

phlptp commented Sep 21, 2019

@henryiii We would need a decision on 1,2 or 3 from the previous question to be able to move forward. I don't really have a strong preference either way. I was inclined towards option 1, but that would break an existing test case.

@phlptp
Copy link
Collaborator Author

phlptp commented Sep 27, 2019

So what I ended up doing with regard to subcommand names, is disable the check if the subcommand is disabled. So if the existing behavior is needed there is a means of allowing it, but in general it would trigger an error.

@phlptp phlptp marked this pull request as ready for review September 27, 2019 14:52
@phlptp
Copy link
Collaborator Author

phlptp commented Sep 28, 2019

@henryiii I think something is wrong with the travis gcc 4.8 build and the azure clang 3.4 builds

@henryiii henryiii force-pushed the add_needs_to_subcommand branch from 9674c45 to fff91ca Compare October 24, 2019 23:11
@henryiii
Copy link
Collaborator

What's the current status? Do you think it's ready for a final review and merge?

@henryiii henryiii force-pushed the add_needs_to_subcommand branch from fff91ca to a460029 Compare October 25, 2019 12:33
@phlptp
Copy link
Collaborator Author

phlptp commented Oct 25, 2019

I think so, I haven't found anything I have wanted to change in a while. I think there is a possibility of more work needed on the help output in relation to the changes from this PR, but I really don't know the best way to present that information yet and I think it will take some experience using it to know for sure.

@henryiii henryiii merged commit 343a730 into CLIUtils:master Oct 25, 2019
@henryiii
Copy link
Collaborator

I think it looks good enough to merge. We can adjust things like help output in the future.

@henryiii henryiii deleted the add_needs_to_subcommand branch October 25, 2019 14:22
@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.

2 participants