diff options
| author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-11-19 22:24:13 -0500 |
|---|---|---|
| committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-11-19 22:24:13 -0500 |
| commit | eee6bf15805fa8ed3ca713a4c6e8edfd9ebc5d4e (patch) | |
| tree | 1ca2646da76dcb0e788e47d2ccf61de5a666e168 /cmd2/__init__.py | |
| parent | 8c00d342ee3967e09cce436d76208238307d1cd4 (diff) | |
| download | cmd2-git-eee6bf15805fa8ed3ca713a4c6e8edfd9ebc5d4e.tar.gz | |
Added capability to override the argument parser class used by cmd2 built-in commands
Diffstat (limited to 'cmd2/__init__.py')
| -rw-r--r-- | cmd2/__init__.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/cmd2/__init__.py b/cmd2/__init__.py index 8e8a8845..8fc5e9f2 100644 --- a/cmd2/__init__.py +++ b/cmd2/__init__.py @@ -11,7 +11,17 @@ except DistributionNotFound: pass from .ansi import style -from .argparse_custom import Cmd2ArgumentParser, CompletionError, CompletionItem +from .argparse_custom import Cmd2ArgumentParser, CompletionError, CompletionItem, set_default_argument_parser + +# Check if user has defined a module that sets a custom value for argparse_custom.DEFAULT_ARGUMENT_PARSER +import argparse +cmd2_parser_module = getattr(argparse, 'cmd2_parser_module', None) +if cmd2_parser_module is not None: + import importlib + importlib.import_module(cmd2_parser_module) + +# Get the current value for argparse_custom.DEFAULT_ARGUMENT_PARSER +from .argparse_custom import DEFAULT_ARGUMENT_PARSER from .cmd2 import Cmd, EmptyStatement from .constants import COMMAND_NAME, DEFAULT_SHORTCUTS from .decorators import categorize, with_argument_list, with_argparser, with_argparser_and_unknown_args, with_category |
