diff --git a/tests/test_cli.py b/tests/test_cli.py index 8475937..7d96d5c 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -155,14 +155,11 @@ def test_empty_storage(tmpdir): result = runner.invoke(cli.app, ['sync']) tmpdir.join('path_b/haha.txt').remove() result = runner.invoke(cli.app, ['sync']) - assert result.output.splitlines() == [ - 'Syncing my_pair', - 'error: {status_name}: Storage "{name}" was completely emptied. Use ' - '"--force-delete {status_name}" to synchronize that emptyness to ' - 'the other side, or delete the status by yourself to restore the ' - 'items from the non-empty side.'.format(status_name='my_pair', - name='my_b') - ] + lines = result.output.splitlines() + assert len(lines) == 2 + assert lines[0] == 'Syncing my_pair' + assert lines[1].startswith('error: my_pair: ' + 'Storage "my_b" was completely emptied.') assert result.exception diff --git a/vdirsyncer/cli.py b/vdirsyncer/cli.py index b3e5b5e..35e7091 100644 --- a/vdirsyncer/cli.py +++ b/vdirsyncer/cli.py @@ -290,7 +290,7 @@ def _create_app(): @app.command() @click.argument('pairs', nargs=-1) - @click.option('--force-delete', multiple=True, + @click.option('--force-delete/--no-force-delete', help=('Disable data-loss protection for the given pairs. ' 'Can be passed multiple times')) @click.option('--max-workers', @@ -311,7 +311,6 @@ def _create_app(): from the pair "bob". ''' general, all_pairs, all_storages = ctx.obj['config'] - force_delete = set(force_delete) cli_logger.debug('Using {} maximal workers.'.format(max_workers)) wq = WorkerQueue(max_workers) @@ -413,9 +412,9 @@ def handle_cli_error(status_name='sync'): except StorageEmpty as e: cli_logger.error( '{status_name}: Storage "{name}" was completely emptied. Use ' - '"--force-delete {status_name}" to synchronize that emptyness to ' - 'the other side, or delete the status by yourself to restore the ' - 'items from the non-empty side.'.format( + '`vdirsyncer sync --force-delete {status_name}` to synchronize ' + 'that emptyness to the other side, or delete the status by ' + 'yourself to restore the items from the non-empty side.'.format( name=e.empty_storage.instance_name, status_name=status_name ) @@ -458,7 +457,7 @@ def sync_collection(wq, pair_name, collection, a, b, pair_options, general, sync( a, b, status, conflict_resolution=pair_options.get('conflict_resolution', None), - force_delete=status_name in force_delete + force_delete=force_delete ) except: if not handle_cli_error(status_name):