summaryrefslogtreecommitdiff
path: root/examples/example.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2021-06-16 16:14:14 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2021-06-17 14:10:24 -0400
commitebb939ba0494648a7eb521023649816cd28be6c4 (patch)
treeda77637440bb65f26bcb05646fcb7396ddf97b8f /examples/example.py
parent525d32cfde6c2f9fecb0ee44972c18d4b0bf614f (diff)
downloadcmd2-git-ebb939ba0494648a7eb521023649816cd28be6c4.tar.gz
Updated all examples to use Cmd2ArgumentParser instead of argparse.ArgumentParser.
This is best practice for consistency of appearance between built-in and custom commands.
Diffstat (limited to 'examples/example.py')
-rwxr-xr-xexamples/example.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/examples/example.py b/examples/example.py
index 4c527076..da6c3c9f 100755
--- a/examples/example.py
+++ b/examples/example.py
@@ -10,7 +10,6 @@ Running `python example.py -t transcript_regex.txt` will run all the commands in
the transcript against example.py, verifying that the output produced matches
the transcript.
"""
-import argparse
import random
import cmd2
@@ -34,7 +33,7 @@ class CmdLineApp(cmd2.Cmd):
self.maxrepeats = 3
self.add_settable(cmd2.Settable('maxrepeats', int, 'max repetitions for speak command', self))
- speak_parser = argparse.ArgumentParser()
+ speak_parser = cmd2.Cmd2ArgumentParser()
speak_parser.add_argument('-p', '--piglatin', action='store_true', help='atinLay')
speak_parser.add_argument('-s', '--shout', action='store_true', help='N00B EMULATION MODE')
speak_parser.add_argument('-r', '--repeat', type=int, help='output [n] times')
@@ -58,7 +57,7 @@ class CmdLineApp(cmd2.Cmd):
do_say = do_speak # now "say" is a synonym for "speak"
do_orate = do_speak # another synonym, but this one takes multi-line input
- mumble_parser = argparse.ArgumentParser()
+ mumble_parser = cmd2.Cmd2ArgumentParser()
mumble_parser.add_argument('-r', '--repeat', type=int, help='how many times to repeat')
mumble_parser.add_argument('words', nargs='+', help='words to say')