summaryrefslogtreecommitdiff
path: root/cmd2/__init__.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2019-11-22 21:57:25 -0500
committerGitHub <noreply@github.com>2019-11-22 21:57:25 -0500
commit1cad8d92b87a227b331c0e86ddbbee25a6742650 (patch)
tree473f2e533aa34f2b4811a01bf18746aaf8471c0c /cmd2/__init__.py
parent8c00d342ee3967e09cce436d76208238307d1cd4 (diff)
parent0d6e9cbd254b8f9911a0d6aad1edb913e95fff45 (diff)
downloadcmd2-git-1cad8d92b87a227b331c0e86ddbbee25a6742650.tar.gz
Merge pull request #812 from python-cmd2/custom_parser
Custom parser
Diffstat (limited to 'cmd2/__init__.py')
-rw-r--r--cmd2/__init__.py12
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