summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorEric Lin <anselor@gmail.com>2018-04-11 11:44:18 -0400
committerEric Lin <anselor@gmail.com>2018-04-11 11:44:18 -0400
commit52bf16c412eb7933eac159ed0fc6363ccc37a82c (patch)
tree70a496ff7eca30f6e0234b8083a41c5fc7dd1199 /examples
parent2ffd342e7523e36f2e0536beca6cf36db5070362 (diff)
downloadcmd2-git-52bf16c412eb7933eac159ed0fc6363ccc37a82c.tar.gz
Fixed issue where categorization is skipped when there's a help_<command> function provided.
In verbose help, added check for argparse usage block (starting with 'usage: '), to skip that block and move to the next comment block Added unit tests for new categorization code Updated example to demonstrate skipping of argparse usage statement
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/help_categories.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/examples/help_categories.py b/examples/help_categories.py
index 2a88edba..8a33e62c 100755
--- a/examples/help_categories.py
+++ b/examples/help_categories.py
@@ -4,7 +4,8 @@
A sample application for tagging categories on commands.
"""
-from cmd2 import Cmd, categorize, __version__
+from cmd2 import Cmd, categorize, __version__, with_argparser
+import argparse
class HelpCategories(Cmd):
@@ -51,6 +52,12 @@ class HelpCategories(Cmd):
"""Redeploy command"""
self.poutput('Redeploy')
+ restart_parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
+ restart_parser.add_argument('when', default='now',
+ choices=['now', 'later', 'sometime', 'whenever'],
+ help='Specify when to restart')
+
+ @with_argparser(restart_parser)
def do_restart(self, _):
"""Restart command"""
self.poutput('Restart')