@@ -9,10 +9,10 @@ following for you:
9
9
1 . Passes the resulting ` argparse.Namespace ` object to your command function. The ` Namespace `
10
10
includes the ` Statement ` object that was created when parsing the command line. It can be
11
11
retrieved by calling ` cmd2_statement.get() ` on the ` Namespace ` .
12
- 1 . Adds the usage message from the argument parser to your command.
13
- 1 . Checks if the ` -h/--help ` option is present, and if so, display the help message for the command
12
+ 1 . Adds the usage message from the argument parser to your command's help .
13
+ 1 . Checks if the ` -h/--help ` option is present, and if so, displays the help message for the command
14
14
15
- These features are all provided by the ` @with_argparser ` decorator which is importable from ` cmd2 ` .
15
+ These features are all provided by the ` @with_argparser ` decorator which is imported from ` cmd2 ` .
16
16
17
17
See the
18
18
[ argparse_example] ( https://github.com/python-cmd2/cmd2/blob/main/examples/argparse_example.py )
@@ -49,7 +49,7 @@ argparser.add_argument('-r', '--repeat', type=int, help='output [n] times')
49
49
argparser.add_argument(' word' , nargs = ' ?' , help = ' word to say' )
50
50
51
51
@with_argparser (argparser)
52
- def do_speak (self , opts )
52
+ def do_speak (self , opts ):
53
53
""" Repeats what you tell me to."""
54
54
arg = opts.word
55
55
if opts.piglatin:
@@ -91,7 +91,7 @@ the `help tag` command displays:
91
91
``` text
92
92
usage: tag [-h] tag content [content ...]
93
93
94
- create a html tag
94
+ create an HTML tag
95
95
96
96
positional arguments:
97
97
tag tag
@@ -101,13 +101,13 @@ optional arguments:
101
101
-h, --help show this help message and exit
102
102
```
103
103
104
- If you would prefer you can set the ` description ` while instantiating the ` argparse.ArgumentParser `
104
+ If you would prefer, you can set the ` description ` while instantiating the ` argparse.ArgumentParser `
105
105
and leave the docstring on your method empty:
106
106
107
107
``` py
108
108
from cmd2 import Cmd2ArgumentParser, with_argparser
109
109
110
- argparser = Cmd2ArgumentParser(description = ' create an html tag' )
110
+ argparser = Cmd2ArgumentParser(description = ' create an HTML tag' )
111
111
argparser.add_argument(' tag' , help = ' tag' )
112
112
argparser.add_argument(' content' , nargs = ' +' , help = ' content to surround with tag' )
113
113
@with_argparser (argparser)
@@ -121,7 +121,7 @@ Now when the user enters `help tag` they see:
121
121
``` text
122
122
usage: tag [-h] tag content [content ...]
123
123
124
- create an html tag
124
+ create an HTML tag
125
125
126
126
positional arguments:
127
127
tag tag
@@ -136,7 +136,7 @@ To add additional text to the end of the generated help message, use the `epilog
136
136
``` py
137
137
from cmd2 import Cmd2ArgumentParser, with_argparser
138
138
139
- argparser = Cmd2ArgumentParser(description = ' create an html tag' ,
139
+ argparser = Cmd2ArgumentParser(description = ' create an HTML tag' ,
140
140
epilog = ' This command cannot generate tags with no content, like <br/>.' )
141
141
argparser.add_argument(' tag' , help = ' tag' )
142
142
argparser.add_argument(' content' , nargs = ' +' , help = ' content to surround with tag' )
@@ -151,7 +151,7 @@ Which yields:
151
151
``` text
152
152
usage: tag [-h] tag content [content ...]
153
153
154
- create an html tag
154
+ create an HTML tag
155
155
156
156
positional arguments:
157
157
tag tag
@@ -195,7 +195,7 @@ class CmdLineApp(cmd2.Cmd):
195
195
self .poutput(arg)
196
196
```
197
197
198
- If you don't want to access the additional attributes on the string passed to you ` do_* ` method you
198
+ If you don't want to access the additional attributes on the string passed to your ` do_* ` method you
199
199
can still have ` cmd2 ` apply shell parsing rules to the user input and pass you a list of arguments
200
200
instead of a string. Apply the ` @with_argument_list ` decorator to those methods that should receive
201
201
an argument list instead of a string:
@@ -320,7 +320,7 @@ def do_foo(self, args: argparse.Namespace) -> None:
320
320
```
321
321
322
322
However, if you do NOT want the custom decorator runtime behavior to occur even in the case of an
323
- ` argparse ` error, then that decorator needs to go ** before** the ` arpgarse ` one, e.g.:
323
+ ` argparse ` error, then that decorator needs to go ** before** the ` argparse ` one, e.g.:
324
324
325
325
``` py
326
326
@my_decorator
@@ -338,9 +338,9 @@ example demonstrates both above cases in a concrete fashion.
338
338
` cmd2 ` argparse decorators add the following attributes to argparse Namespaces. To avoid naming
339
339
collisions, do not use any of the names for your argparse arguments.
340
340
341
- - ` cmd2_statement ` - ` cmd2.Cmd2AttributeWrapper ` object containing ` cmd2.Statement ` object that was
342
- created when parsing the command line.
341
+ - ` cmd2_statement ` - ` cmd2.Cmd2AttributeWrapper ` object containing the ` cmd2.Statement ` object that
342
+ was created when parsing the command line.
343
343
- ` cmd2_handler ` - ` cmd2.Cmd2AttributeWrapper ` object containing a subcommand handler function or
344
344
` None ` if one was not set.
345
- - ` __subcmd_handler__ ` - used by cmd2 to identify the handler for a subcommand created with
345
+ - ` __subcmd_handler__ ` - used by cmd2 to identify the handler for a subcommand created with the
346
346
` @cmd2.as_subcommand_to ` decorator.
0 commit comments