From 9b83afe4919a1a5d3ca051a43e0a07ab0222a43f Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Sun, 26 Feb 2023 17:05:56 -0800 Subject: [PATCH] With the "create" action, only one of "--list" ("--files") and "--progress" flags can be used. --- NEWS | 2 ++ borgmatic/commands/arguments.py | 5 +++++ tests/integration/commands/test_arguments.py | 7 +++++++ 3 files changed, 14 insertions(+) diff --git a/NEWS b/NEWS index 24b49de..8fad15f 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,7 @@ 1.7.8.dev0 * #621: Add optional authentication to the ntfy monitoring hook. + * With the "create" action, only one of "--list" ("--files") and "--progress" flags can be used. + This lines up with the new behavior in Borg 2.0.0b5. 1.7.7 * #642: Add MySQL database hook "add_drop_database" configuration option to control whether dumped diff --git a/borgmatic/commands/arguments.py b/borgmatic/commands/arguments.py index 7a1a34a..6061da9 100644 --- a/borgmatic/commands/arguments.py +++ b/borgmatic/commands/arguments.py @@ -833,6 +833,11 @@ def parse_arguments(*unparsed_arguments): 'The --excludes flag has been replaced with exclude_patterns in configuration.' ) + if 'create' in arguments and arguments['create'].list_files and arguments['create'].progress: + raise ValueError( + 'With the create action, only one of --list (--files) and --progress flags can be used.' + ) + if ( ('list' in arguments and 'rinfo' in arguments and arguments['list'].json) or ('list' in arguments and 'info' in arguments and arguments['list'].json) diff --git a/tests/integration/commands/test_arguments.py b/tests/integration/commands/test_arguments.py index f2d2049..cb001c1 100644 --- a/tests/integration/commands/test_arguments.py +++ b/tests/integration/commands/test_arguments.py @@ -422,6 +422,13 @@ def test_parse_arguments_with_list_flag_but_no_relevant_action_raises_value_erro module.parse_arguments('--list', 'rcreate') +def test_parse_arguments_disallows_list_with_progress_for_create_action(): + flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default']) + + with pytest.raises(ValueError): + module.parse_arguments('create', '--list', '--progress') + + def test_parse_arguments_allows_json_with_list_or_info(): flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])