From 157efc589cae43e5fb37ac38575d8cdfcd11c9b8 Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Thu, 20 Feb 2020 12:33:23 -0500 Subject: Moved categorize() to utils.py and made set_parser_prog() non-public --- cmd2/utils.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'cmd2/utils.py') diff --git a/cmd2/utils.py b/cmd2/utils.py index 6a67c43f..971a22ce 100644 --- a/cmd2/utils.py +++ b/cmd2/utils.py @@ -964,3 +964,18 @@ def get_styles_in_text(text: str) -> Dict[int, str]: start += len(match.group()) return styles + + +def categorize(func: Union[Callable, Iterable[Callable]], category: str) -> None: + """Categorize a function. + + The help command output will group this function under the specified category heading + + :param func: function or list of functions to categorize + :param category: category to put it in + """ + if isinstance(func, Iterable): + for item in func: + setattr(item, constants.CMD_ATTR_HELP_CATEGORY, category) + else: + setattr(func, constants.CMD_ATTR_HELP_CATEGORY, category) -- cgit v1.2.1