summaryrefslogtreecommitdiff
path: root/examples/argparse_example.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/argparse_example.py')
-rwxr-xr-xexamples/argparse_example.py27
1 files changed, 1 insertions, 26 deletions
diff --git a/examples/argparse_example.py b/examples/argparse_example.py
index fbb2b1dc..ca2173e7 100755
--- a/examples/argparse_example.py
+++ b/examples/argparse_example.py
@@ -14,8 +14,7 @@ verifying that the output produced matches the transcript.
import argparse
import sys
-from cmd2 import Cmd, options, with_argparser, with_argument_list
-from optparse import make_option
+from cmd2 import Cmd, with_argparser, with_argument_list
class CmdLineApp(Cmd):
@@ -85,30 +84,6 @@ class CmdLineApp(Cmd):
self.perror("tagg requires at least 2 arguments")
- # @options uses the python optparse module which has been deprecated
- # since 2011. Use @with_argument_parser instead, which utilizes the
- # python argparse module
- @options([make_option('-p', '--piglatin', action="store_true", help="atinLay"),
- make_option('-s', '--shout', action="store_true", help="N00B EMULATION MODE"),
- make_option('-r', '--repeat', type="int", help="output [n] times")
- ])
- def do_deprecated_speak(self, arg, opts=None):
- """Repeats what you tell me to."""
- words = []
- for word in arg:
- if opts.piglatin:
- word = '%s%say' % (word[1:], word[0])
- if opts.shout:
- arg = arg.upper()
- words.append(word)
- repetitions = opts.repeat or 1
- for i in range(min(repetitions, self.maxrepeats)):
- self.stdout.write(' '.join(words))
- self.stdout.write('\n')
- # self.stdout.write is better than "print", because Cmd can be
- # initialized with a non-standard output destination
-
-
if __name__ == '__main__':
# You can do your custom Argparse parsing here to meet your application's needs
parser = argparse.ArgumentParser(description='Process the arguments however you like.')