summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorEric Lin <anselor@gmail.com>2018-04-11 15:11:52 -0400
committerEric Lin <anselor@gmail.com>2018-04-11 15:11:52 -0400
commit33decb449c61e2a78877563309929c4686ea081e (patch)
tree85ce1f9b2b893f9daee08b7c61d098bd0752ed2b /examples
parent52bf16c412eb7933eac159ed0fc6363ccc37a82c (diff)
downloadcmd2-git-33decb449c61e2a78877563309929c4686ea081e.tar.gz
Added a with_category decorator that can be used to tag a command category.
Changed the detection of with_argparse decorated commands to be less hacky/brittle. Now it tags the function with help_summary. Fixed issue with handling commands that provide a custom help_ function. We can now redirect the output to a string to be formatted with the other commands. Added some documentation explaining the new help categories. Updated unit tests.
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/help_categories.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/examples/help_categories.py b/examples/help_categories.py
index 8a33e62c..e7e3373d 100755
--- a/examples/help_categories.py
+++ b/examples/help_categories.py
@@ -4,7 +4,7 @@
A sample application for tagging categories on commands.
"""
-from cmd2 import Cmd, categorize, __version__, with_argparser
+from cmd2 import Cmd, categorize, __version__, with_argparser, with_category
import argparse
@@ -24,14 +24,14 @@ class HelpCategories(Cmd):
"""Connect command"""
self.poutput('Connect')
+ # Tag the above command functions under the category Connecting
+ categorize(do_connect, CMD_CAT_CONNECTING)
+
+ @with_category(CMD_CAT_CONNECTING)
def do_which(self, _):
"""Which command"""
self.poutput('Which')
- # Tag the above command functions under the category Connecting
- categorize(do_connect, CMD_CAT_CONNECTING)
- categorize(do_which, CMD_CAT_CONNECTING)
-
def do_list(self, _):
"""List command"""
self.poutput('List')
@@ -58,6 +58,7 @@ class HelpCategories(Cmd):
help='Specify when to restart')
@with_argparser(restart_parser)
+ @with_category(CMD_CAT_APP_MGMT)
def do_restart(self, _):
"""Restart command"""
self.poutput('Restart')
@@ -84,7 +85,6 @@ class HelpCategories(Cmd):
do_start,
do_sessions,
do_redeploy,
- do_restart,
do_expire,
do_undeploy,
do_stop,