diff options
author | Eric Lin <anselor@gmail.com> | 2018-04-09 18:14:31 -0400 |
---|---|---|
committer | Eric Lin <anselor@gmail.com> | 2018-04-09 18:14:31 -0400 |
commit | ef23633daba9538360af61d7547e8d0d0f6c1139 (patch) | |
tree | 834317ca11c5619348af6344688f075e5f7d174e /cmd2.py | |
parent | 5d1e981ee18136d41574c20e10a77f1b0e8b30a1 (diff) | |
download | cmd2-git-ef23633daba9538360af61d7547e8d0d0f6c1139.tar.gz |
Added a convenience function for tagging command categories.
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. |