diff options
Diffstat (limited to 'cmd2.py')
-rwxr-xr-x | cmd2.py | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -42,6 +42,7 @@ import six import sys import tempfile import traceback +from typing import Union, Callable import unittest from code import InteractiveConsole @@ -212,6 +213,18 @@ REDIRECTION_CHARS = ['|', '<', '>'] HELP_CATEGORY = 'help_category' +def categorize(func: Union[Callable, Iterable], category: str): + """ + Categorize a function + The help command output will group this function under the specified category heading + """ + if isinstance(func, Iterable): + for item in func: + setattr(item, HELP_CATEGORY, category) + else: + setattr(func, HELP_CATEGORY, category) + + def set_posix_shlex(val): """ Allows user of cmd2 to choose between POSIX and non-POSIX splitting of args for decorated commands. |