cli: extend control over defaults #21308
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The PR extends functionality of the cli module to allow more control over defaults.
Creating an application with the cli module and default commands and will result in something like:
An example result with more direct control over defaults could look like (keeps some default flags):
Current customization possibilities are limited as they only disable flag and command at once.
The updated functionality would allow full control
The current
disable_man
,disable_help
,disable_version
flags are deprecated but will continue to work.I had this potential change sitting since October but didn't submit it because there were some issues regarding its implementation. After the recent development and since private fields are now actually treated as private to a module, this change can work out. Also, I find myself in the situation again where I'd like to be able to easily disable default flags or commands but not both when working with the cli module. So I'd like to give it a shot.
Would just need to be refined and covered with a test.