summaryrefslogtreecommitdiff
path: root/cmd2/cmd2.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2020-09-17 20:09:40 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2020-09-17 20:09:40 -0400
commited3f9094c013cce618571a8718c76f5e0dbaba3d (patch)
treebfb7bbce00bad232a643c550f95b01831f7c0dc0 /cmd2/cmd2.py
parentcf9516e5d25df5e4e330f75ab0f800ba8b4217c8 (diff)
parent92b8a38d66d255027a0440c45582d319f2694aab (diff)
downloadcmd2-git-ed3f9094c013cce618571a8718c76f5e0dbaba3d.tar.gz
Merge branch 'master' into silence
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r--cmd2/cmd2.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index badae1d8..9b561889 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -46,7 +46,7 @@ from . import ansi, constants, plugin, utils
from .argparse_custom import DEFAULT_ARGUMENT_PARSER, CompletionItem
from .clipboard import can_clip, get_paste_buffer, write_to_paste_buffer
from .command_definition import CommandSet
-from .constants import COMMAND_FUNC_PREFIX, COMPLETER_FUNC_PREFIX, HELP_FUNC_PREFIX
+from .constants import CLASS_ATTR_DEFAULT_HELP_CATEGORY, COMMAND_FUNC_PREFIX, COMPLETER_FUNC_PREFIX, HELP_FUNC_PREFIX
from .decorators import with_argparser, as_subcommand_to
from .exceptions import (
CommandSetRegistrationError,
@@ -483,6 +483,8 @@ class Cmd(cmd.Cmd):
predicate=lambda meth: isinstance(meth, Callable)
and hasattr(meth, '__name__') and meth.__name__.startswith(COMMAND_FUNC_PREFIX))
+ default_category = getattr(cmdset, CLASS_ATTR_DEFAULT_HELP_CATEGORY, None)
+
installed_attributes = []
try:
for method_name, method in methods:
@@ -505,6 +507,9 @@ class Cmd(cmd.Cmd):
self._cmd_to_command_sets[command] = cmdset
+ if default_category and not hasattr(method, constants.CMD_ATTR_HELP_CATEGORY):
+ utils.categorize(method, default_category)
+
self._installed_command_sets.append(cmdset)
self._register_subcommands(cmdset)