Fix for another subaction argument-parsing edge case (#712).

This commit is contained in:
Dan Helfman 2023-06-21 10:41:32 -07:00
parent 147516ae3f
commit 248f82d6f6
2 changed files with 17 additions and 7 deletions

View file

@ -161,18 +161,22 @@ def parse_arguments_for_actions(unparsed_arguments, action_parsers):
subaction_parsers = get_subaction_parsers(action_parser)
# Parse with subaction parsers, if any.
# But first parse with subaction parsers, if any.
if subaction_parsers:
subactions_parsed = False
for subaction_name, subaction_parser in subaction_parsers.items():
remaining_action_arguments.append(
parse_and_record_action_arguments(
tuple(
argument
for argument in parse_and_record_action_arguments(
unparsed_arguments,
arguments,
subaction_parser,
subaction_name,
)
if argument != action_name
)
)
if subaction_name in arguments:

View file

@ -587,7 +587,13 @@ def test_parse_arguments_config_with_subaction_and_required_flags_does_not_raise
module.parse_arguments('config', 'bootstrap', '--repository', 'repo.borg')
def test_parse_arguments_config_with_subaction_and_global_flags_does_not_raise(capsys):
def test_parse_arguments_config_with_subaction_and_global_flags_at_start_does_not_raise(capsys):
flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
module.parse_arguments('--verbosity', '1', 'config', 'bootstrap', '--repository', 'repo.borg')
def test_parse_arguments_config_with_subaction_and_global_flags_at_end_does_not_raise(capsys):
flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
module.parse_arguments('config', 'bootstrap', '--repository', 'repo.borg', '--verbosity', '1')