-
Notifications
You must be signed in to change notification settings - Fork 364
Option groups #227
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
Option groups #227
Conversation
I like the addition of the required option count, need to think about the named group App subclass idea, it might be better just to integrate the extra functionality into App. Also, you should be able to move that free function into a member, just either predeclare or make it a template function with a wasted automatic template parameter, I use that trick somewhere else in App or Option. Will revisit. A nice example of usage would help decide if it is a good idea to pursue. |
Codecov Report
@@ Coverage Diff @@
## master #227 +/- ##
==========================================
- Coverage 100% 99.71% -0.29%
==========================================
Files 12 12
Lines 2057 2089 +32
==========================================
+ Hits 2057 2083 +26
- Misses 0 6 +6
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #227 +/- ##
======================================
Coverage 100% 100%
======================================
Files 12 12
Lines 2212 2402 +190
======================================
+ Hits 2212 2402 +190
Continue to review full report at Codecov.
|
6bb1aff
to
88f4bf0
Compare
6be3914
to
0335da2
Compare
540b30b
to
bd05d02
Compare
I added a ranges example as shown in #88. I think the help needs some work and I need more test cases and docs but I think that example can be run with this PR. The basic idea is to treat option groups the same as options for counting purposes, and then allow options to exclude subcommands, and subcommands to exclude others. |
I'd like a readme update, even if just so I can get a good feel for what this affects from a user perspective. Also, could this be able to replace the |
I thought about that a little, but if you were to make the current groups use the new option groups it would alter the parse order, which could be important for positional arguments. And I think if you had two lists you lose some of the composability aspects of nameless subcommands, and dealing with switching between them could be a tricky issue. Maybe worth exploring after getting a little experience with how this interacts with everything else. Your ideas on full group objects might come into play as well. |
I will work on the Readme next, but probably won't be able to finish it until this evening or tomorrow morning. |
add a validation check on min options to make sure it is even possible to succeed. add some additional tests to cover code paths and potential errors. add a number of additional tests and checks and fix some issues with the add function in option_groups clean up example and help formatting add option_groups example to play with move create_option_group to a member function using a dummy template add some optionGroup tests add min and max options calls and an associated Error call
a2570fa
to
86d78f5
Compare
I updated the readMe with the changes, at least a first draft of the update. |
f4b09a5
to
48cd1eb
Compare
Is this ready? I think we can merge, possibly iterating before the next release. |
At your discretion, If you are happy with the readme updates I think it is ready. I am guessing there will need to be a few tweaks as there is more experience with it, but I don't know what those might be at the moment. |
I’m going to consider a few changes/renames in a seperate issue in a few days. Thanks! |
This PR add require_options(min,max) functionality to App, the functionality is similar to require_subcommand.
Also create a subclass for Option_group which is currently a limited wrapper around an App, which constructs a nameless subcommand on an app.
the option_group is created through a standalone function so App doesn't have to be aware of the existence of Option_group. This should address #88 as @AlexanderAmelkin, as he is correct that while a nameless subcommand with the require_option will work it does seem kind of a hack. With the option_group we may be able to add some additional better help and possibly some other features related to clusters of options though I am not sure what that might be at this point.
more tests would need to be added if we like this approach.
I think this is an alternative to the radio_id alternative that @AlexanderAmelkin is working on, not sure which is preferred by @henryiii.