@@ -55,10 +55,9 @@ method, which will contain the results of ``ArgumentParser.parse_args()``.
55
55
56
56
Here's what it looks like::
57
57
58
- import argparse
59
- from cmd2 import with_argparser
58
+ from cmd2 import Cmd2ArgumentParser, with_argparser
60
59
61
- argparser = argparse.ArgumentParser ()
60
+ argparser = Cmd2ArgumentParser ()
62
61
argparser.add_argument('-p', '--piglatin', action='store_true', help='atinLay')
63
62
argparser.add_argument('-s', '--shout', action='store_true', help='N00B EMULATION MODE')
64
63
argparser.add_argument('-r', '--repeat', type=int, help='output [n] times')
@@ -106,10 +105,9 @@ docstring for the ``do_*`` method is used to set the description for the
106
105
107
106
With this code::
108
107
109
- import argparse
110
- from cmd2 import with_argparser
108
+ from cmd2 import Cmd2ArgumentParser, with_argparser
111
109
112
- argparser = argparse.ArgumentParser ()
110
+ argparser = Cmd2ArgumentParser ()
113
111
argparser.add_argument('tag', help='tag')
114
112
argparser.add_argument('content', nargs='+', help='content to surround with tag')
115
113
@with_argparser(argparser)
@@ -137,10 +135,9 @@ the ``help tag`` command displays:
137
135
If you would prefer you can set the ``description `` while instantiating the
138
136
``argparse.ArgumentParser `` and leave the docstring on your method empty::
139
137
140
- import argparse
141
- from cmd2 import with_argparser
138
+ from cmd2 import Cmd2ArgumentParser, with_argparser
142
139
143
- argparser = argparse.ArgumentParser (description='create an html tag')
140
+ argparser = Cmd2ArgumentParser (description='create an html tag')
144
141
argparser.add_argument('tag', help='tag')
145
142
argparser.add_argument('content', nargs='+', help='content to surround with tag')
146
143
@with_argparser(argparser)
@@ -166,11 +163,10 @@ Now when the user enters ``help tag`` they see:
166
163
167
164
To add additional text to the end of the generated help message, use the ``epilog `` variable::
168
165
169
- import argparse
170
- from cmd2 import with_argparser
166
+ from cmd2 import Cmd2ArgumentParser, with_argparser
171
167
172
- argparser = argparse.ArgumentParser (description='create an html tag',
173
- epilog='This command cannot generate tags with no content, like <br/>.')
168
+ argparser = Cmd2ArgumentParser (description='create an html tag',
169
+ epilog='This command cannot generate tags with no content, like <br/>.')
174
170
argparser.add_argument('tag', help='tag')
175
171
argparser.add_argument('content', nargs='+', help='content to surround with tag')
176
172
@with_argparser(argparser)
@@ -265,10 +261,9 @@ strings, then decorate the command method with the
265
261
266
262
Here's what it looks like::
267
263
268
- import argparse
269
- from cmd2 import with_argparser
264
+ from cmd2 import Cmd2ArgumentParser, with_argparser
270
265
271
- dir_parser = argparse.ArgumentParser ()
266
+ dir_parser = Cmd2ArgumentParser ()
272
267
dir_parser.add_argument('-l', '--long', action='store_true', help="display in long format with one item per line")
273
268
274
269
@with_argparser(dir_parser, with_unknown_args=True)
0 commit comments