Repository navigation
Make a command's help category public as Cmd.get_command_category() - #1856
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1856 +/- ##
=======================================
Coverage 99.76% 99.76%
=======================================
Files 23 23
Lines 6773 6773
=======================================
Hits 6757 6757
Misses 16 16
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
…disabled command's function is its replacement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Makes
Cmd._get_command_category()public asCmd.get_command_category(). It returns the helpcategory which
helplists a command under.An application which describes its own commands needs a command's category, and until now the only
way to get it was the private method. #1852 is the first such case.
What changes
Cmd.get_command_category(func)is the old_get_command_category()under a public name,with the same behavior. Its docstring now gives the order in which the category is found:
@with_categoryorcategorize()DEFAULT_CATEGORYof the class which defines the command, which may be aCommandSetor abase class
DEFAULT_CATEGORY, when the defining class has none, as with a plainmixin
cmd2.pyuse the new name. The private name is removed, not kept as an alias,since it was never public API. No caller of it remains in
cmd2,docsorexamples:git grep -n _get_command_category -- cmd2 docs examplesprints nothing.docs/features/help.mdsays how to find a command's category.tests/test_categories.pycovers each of the three sources of the category, and thatthe private name is gone.
4.5.0 (TBD)heading.Merging
This goes in 4.5.0, so it should be merged only after 4.4.5 is released. Until then it is a draft.
#1855 is built on this branch.
Design documents
In the python-cmd2/design repository, this is Stage 1 of:
Task 1
Part of #1852.