diff options
author | Eric Lin <anselor@gmail.com> | 2020-09-08 23:06:27 -0400 |
---|---|---|
committer | Eric Lin <anselor@gmail.com> | 2020-09-08 23:06:27 -0400 |
commit | 5791c153dfdae2f140b6b0d8862b505fc3084112 (patch) | |
tree | b0e2e4239d5dcab1717dd4c04844b176074affe3 /cmd2/command_definition.py | |
parent | 5bc9b967d347356556d30bb04f0a2a9f7662aa06 (diff) | |
download | cmd2-git-default_categories.tar.gz |
Start to some improvements to default categories. Next: tag CommandSet classes with category name and search for default categories when a command is added to cmd2.Cmddefault_categories
Diffstat (limited to 'cmd2/command_definition.py')
-rw-r--r-- | cmd2/command_definition.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/cmd2/command_definition.py b/cmd2/command_definition.py index 64adaada..96bd9c46 100644 --- a/cmd2/command_definition.py +++ b/cmd2/command_definition.py @@ -6,6 +6,7 @@ from typing import Optional, Type from .constants import COMMAND_FUNC_PREFIX from .exceptions import CommandSetRegistrationError +from .utils import get_defining_class # Allows IDEs to resolve types without impacting imports at runtime, breaking circular dependency issues try: # pragma: no cover @@ -32,7 +33,8 @@ def with_default_category(category: str): from .decorators import with_category methods = inspect.getmembers( cls, - predicate=lambda meth: inspect.isfunction(meth) and meth.__name__.startswith(COMMAND_FUNC_PREFIX)) + predicate=lambda meth: inspect.isfunction(meth) and meth.__name__.startswith(COMMAND_FUNC_PREFIX) + and meth in inspect.getmro(cls)[0].__dict__.values()) category_decorator = with_category(category) for method in methods: if not hasattr(method[1], CMD_ATTR_HELP_CATEGORY): |