diff options
author | kotfu <kotfu@kotfu.net> | 2020-02-14 21:02:02 -0700 |
---|---|---|
committer | kotfu <kotfu@kotfu.net> | 2020-02-14 21:03:00 -0700 |
commit | 51c831d2f28609c736a0d649b04e7d2e3b3d742a (patch) | |
tree | a449bb1165da818b404c0b905d54af45c0c4e503 /cmd2/utils.py | |
parent | 16d7cfb3de0469366b1976a2e2cd1f7f68b6d130 (diff) | |
download | cmd2-git-51c831d2f28609c736a0d649b04e7d2e3b3d742a.tar.gz |
move `categorize()` to `utils.py` and make `set_parser_prog` a private method
Diffstat (limited to 'cmd2/utils.py')
-rw-r--r-- | cmd2/utils.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/cmd2/utils.py b/cmd2/utils.py index e324c2f1..74df7444 100644 --- a/cmd2/utils.py +++ b/cmd2/utils.py @@ -404,6 +404,21 @@ def get_exes_in_path(starts_with: str) -> List[str]: return list(exes_set) +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) + + class StdSim: """ Class to simulate behavior of sys.stdout or sys.stderr. |