summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/cmd2.py b/cmd2.py
index c2cea659..1d2751c4 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -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.