diff options
Diffstat (limited to 'examples/override_parser.py')
| -rwxr-xr-x | examples/override_parser.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/examples/override_parser.py b/examples/override_parser.py index 00161ef6..2e778c07 100755 --- a/examples/override_parser.py +++ b/examples/override_parser.py @@ -6,20 +6,19 @@ The standard parser used by cmd2 built-in commands is Cmd2ArgumentParser. The following code shows how to override it with your own parser class. """ -# First set a value called argparse.cmd2_parser_module with the module that defines the custom parser +# First set a value called argparse.cmd2_parser_module with the module that defines the custom parser. # See the code for custom_parser.py. It simply defines a parser and calls cmd2.set_default_argument_parser() # with the custom parser's type. import argparse -# Next import stuff from cmd2. It will import your module just before the cmd2.Cmd class file is imported +argparse.cmd2_parser_module = 'examples.custom_parser' + +# Next import from cmd2. It will import your module just before the cmd2.Cmd class file is imported # and therefore override the parser class it uses on its commands. from cmd2 import ( cmd2, ) -argparse.cmd2_parser_module = 'examples.custom_parser' - - if __name__ == '__main__': import sys |
