summaryrefslogtreecommitdiff
path: root/cmd2/utils.py
diff options
context:
space:
mode:
authorEric Lin <anselor@gmail.com>2020-09-10 09:15:05 -0400
committeranselor <anselor@gmail.com>2020-09-11 13:50:45 -0400
commit872da20feba57f42dde204da01dc48c4c87e1b54 (patch)
tree37f7812aae5eddac9d8d37ead8b22828378e7497 /cmd2/utils.py
parent6093e5e9c1b6366c67323f090d21696e867b6625 (diff)
downloadcmd2-git-872da20feba57f42dde204da01dc48c4c87e1b54.tar.gz
Changes default category to be heritable by default - meaning that subclasses will inherit the parent class's default category.
Adds optional flag to disable heritability.
Diffstat (limited to 'cmd2/utils.py')
-rw-r--r--cmd2/utils.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/cmd2/utils.py b/cmd2/utils.py
index a2b1c854..d396fb6a 100644
--- a/cmd2/utils.py
+++ b/cmd2/utils.py
@@ -1038,7 +1038,10 @@ def categorize(func: Union[Callable, Iterable[Callable]], category: str) -> None
for item in func:
setattr(item, constants.CMD_ATTR_HELP_CATEGORY, category)
else:
- setattr(func, constants.CMD_ATTR_HELP_CATEGORY, category)
+ if inspect.ismethod(func):
+ setattr(func.__func__, constants.CMD_ATTR_HELP_CATEGORY, category)
+ else:
+ setattr(func, constants.CMD_ATTR_HELP_CATEGORY, category)
def get_defining_class(meth):