diff --git a/swh/deposit/cli/client.py b/swh/deposit/cli/client.py --- a/swh/deposit/cli/client.py +++ b/swh/deposit/cli/client.py @@ -203,21 +203,21 @@ metadata = generate_metadata_file(name, slug, authors, temp_dir) elif not archive_deposit and not partial and not deposit_id: # If we meet all the following conditions: - # * there is not an archive-only deposit + # * this is not an archive-only deposit request # * it is not part of a multipart deposit (either create/update # or finish) # * it misses either name or authors raise InputError( - "Either a metadata file (--metadata) or both --author and " - "--name must be provided, unless this is an archive-only " - "deposit." + "For metadata deposit request, either a metadata file with " + "--metadata or both --author and --name must be provided. " + "If this is an archive deposit request, none is required." ) elif name or authors: # If we are generating metadata, then all mandatory metadata # must be present raise InputError( - "Either a metadata file (--metadata) or both --author and " - "--name must be provided." + "For metadata deposit request, either a metadata file with " + "--metadata or both --author and --name must be provided." ) else: # TODO: this is a multipart deposit, we might want to check that @@ -225,8 +225,8 @@ pass elif name or authors: raise InputError( - "Using a metadata file (--metadata) is incompatible with " - "--author and --name, which are used to generate one." + "Using --metadata flag is incompatible with both " + "--author and --name (Those are used to generate one metadata file)." ) if metadata_deposit: @@ -238,7 +238,7 @@ if metadata_deposit and not metadata: raise InputError( "Metadata deposit must be provided for metadata " - "deposit (either a filepath or --name and --author)" + "deposit, either a filepath with --metadata or --name and --author" ) if not archive and not metadata and partial: diff --git a/swh/deposit/tests/cli/test_client.py b/swh/deposit/tests/cli/test_client.py --- a/swh/deposit/tests/cli/test_client.py +++ b/swh/deposit/tests/cli/test_client.py @@ -231,9 +231,10 @@ "swh.deposit.cli.client", logging.ERROR, ( - "Problem during parsing options: Either a metadata file" - " (--metadata) or both --author and --name must be provided, " - "unless this is an archive-only deposit." + "Problem during parsing options: " + "For metadata deposit request, either a metadata file with " + "--metadata or both --author and --name must be provided. " + "If this is an archive deposit request, none is required." ), ) assert expected_error_log_record in caplog.record_tuples @@ -296,9 +297,9 @@ "swh.deposit.cli.client", logging.ERROR, ( - "Problem during parsing options: Using a metadata file " - "(--metadata) is incompatible with --author and --name, " - "which are used to generate one." + "Problem during parsing options: " + "Using --metadata flag is incompatible with both " + "--author and --name (Those are used to generate one metadata file)." ), ) assert expected_error_log_record_2 in caplog.record_tuples