summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd2/__init__.py3
-rw-r--r--cmd2/argparse_custom.py1
-rw-r--r--cmd2/cmd2.py15
-rw-r--r--tests/test_argparse_completer.py3
4 files changed, 14 insertions, 8 deletions
diff --git a/cmd2/__init__.py b/cmd2/__init__.py
index 776e783c..137b3115 100644
--- a/cmd2/__init__.py
+++ b/cmd2/__init__.py
@@ -5,7 +5,7 @@
import sys
-# For python 3.8 and late
+# For python 3.8 and later
if sys.version_info >= (3, 8):
import importlib.metadata as importlib_metadata
else:
@@ -38,6 +38,7 @@ if cmd2_parser_module is not None:
importlib.import_module(cmd2_parser_module)
from .argparse_completer import DEFAULT_COMMAND_COMPLETER, set_default_command_completer_type
+
# Get the current value for argparse_custom.DEFAULT_ARGUMENT_PARSER
from .argparse_custom import DEFAULT_ARGUMENT_PARSER
from .cmd2 import Cmd
diff --git a/cmd2/argparse_custom.py b/cmd2/argparse_custom.py
index 2bcb0af9..14f3c110 100644
--- a/cmd2/argparse_custom.py
+++ b/cmd2/argparse_custom.py
@@ -702,6 +702,7 @@ def register_argparse_argument_parameter(param_name: str, param_type: Optional[T
CUSTOM_ACTION_ATTRIBS.add(param_name)
+
############################################################################################################
# Patch _ActionsContainer.add_argument with our wrapper to support more arguments
############################################################################################################
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index a1707aee..b0637ad2 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -3117,8 +3117,9 @@ class Cmd(cmd.Cmd):
" alias create save_results print_results \">\" out.txt\n"
)
- alias_create_parser = argparse_custom.DEFAULT_ARGUMENT_PARSER(description=alias_create_description,
- epilog=alias_create_epilog)
+ alias_create_parser = argparse_custom.DEFAULT_ARGUMENT_PARSER(
+ description=alias_create_description, epilog=alias_create_epilog
+ )
alias_create_parser.add_argument('name', help='name of this alias')
alias_create_parser.add_argument(
'command', help='what the alias resolves to', choices_provider=_get_commands_aliases_and_macros_for_completion
@@ -3300,8 +3301,9 @@ class Cmd(cmd.Cmd):
" will only complete paths while typing a macro."
)
- macro_create_parser = argparse_custom.DEFAULT_ARGUMENT_PARSER(description=macro_create_description,
- epilog=macro_create_epilog)
+ macro_create_parser = argparse_custom.DEFAULT_ARGUMENT_PARSER(
+ description=macro_create_description, epilog=macro_create_epilog
+ )
macro_create_parser.add_argument('name', help='name of this macro')
macro_create_parser.add_argument(
'command', help='what the macro resolves to', choices_provider=_get_commands_aliases_and_macros_for_completion
@@ -3689,8 +3691,9 @@ class Cmd(cmd.Cmd):
result = "\n".join('{}: {}'.format(sc[0], sc[1]) for sc in sorted_shortcuts)
self.poutput(f"Shortcuts for other commands:\n{result}")
- eof_parser = argparse_custom.DEFAULT_ARGUMENT_PARSER(description="Called when Ctrl-D is pressed",
- epilog=INTERNAL_COMMAND_EPILOG)
+ eof_parser = argparse_custom.DEFAULT_ARGUMENT_PARSER(
+ description="Called when Ctrl-D is pressed", epilog=INTERNAL_COMMAND_EPILOG
+ )
@with_argparser(eof_parser)
def do_eof(self, _: argparse.Namespace) -> Optional[bool]:
diff --git a/tests/test_argparse_completer.py b/tests/test_argparse_completer.py
index 11745429..11ae2a42 100644
--- a/tests/test_argparse_completer.py
+++ b/tests/test_argparse_completer.py
@@ -1149,7 +1149,6 @@ def test_complete_standalone(ac_app, flag, completions):
class CustomCompleter(argparse_completer.ArgparseCompleter):
-
def _complete_flags(self, text: str, line: str, begidx: int, endidx: int, matched_flags: List[str]) -> List[str]:
"""Override so arguments with 'always_complete' set to True will always be completed"""
for flag in matched_flags:
@@ -1171,6 +1170,7 @@ class CustomCompleterApp(cmd2.Cmd):
"""Test command that will be manually wrapped to use argparse"""
print(args)
+
@pytest.fixture
def custom_completer_app():
@@ -1180,6 +1180,7 @@ def custom_completer_app():
yield app
argparse_completer.set_default_command_completer_type(argparse_completer.ArgparseCompleter)
+
@pytest.mark.parametrize(
'command_and_args, text, output_contains, first_match',
[