summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorEric Lin <anselor@gmail.com>2021-08-19 17:03:42 -0400
committeranselor <anselor@gmail.com>2021-08-23 14:17:12 -0400
commit49805324772ec5fcd06217f4f0a241a9a8d07960 (patch)
treea1647a18085df118bbe12dc37c67104f2817024b /examples
parent6d771e96c0507d9ef4ad3eaaf4bc83669396e591 (diff)
downloadcmd2-git-49805324772ec5fcd06217f4f0a241a9a8d07960.tar.gz
* New function `set_default_command_completer_type()` allows developer to extend and modify the
behavior of `ArgparseCompleter`. * New function `register_argparse_argument_parameter()` allows developers to specify custom parameters to be passed to the argparse parser's `add_argument()` method. These parameters will become accessible in the resulting argparse Action object when modifying `ArgparseCompleter` behavior.
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/override_parser.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/examples/override_parser.py b/examples/override_parser.py
index 00161ef6..bbe9f6e2 100755
--- a/examples/override_parser.py
+++ b/examples/override_parser.py
@@ -11,15 +11,14 @@ The following code shows how to override it with your own parser class.
# with the custom parser's type.
import argparse
+argparse.cmd2_parser_module = 'examples.custom_parser'
+
# Next import stuff 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