Skip to content
Snippets Groups Projects
Commit 7b2cc1fa authored by Stefano Zacchiroli's avatar Stefano Zacchiroli
Browse files

CLI: require explicit "-" to identify via stdin

parent 6ac6cb75
No related branches found
No related tags found
No related merge requests found
......@@ -169,6 +169,8 @@ def identify(obj_type, verify, show_filename, follow_symlinks, objects):
\b
https://docs.softwareheritage.org/devel/swh-model/persistent-identifiers.html
Tip: you can pass "-" to identify the content of standard input.
\b
Examples:
......@@ -189,7 +191,7 @@ def identify(obj_type, verify, show_filename, follow_symlinks, objects):
""" # NoQA # overlong lines in shell examples are fine
if not objects:
objects = ["-"]
raise click.UsageError("no object given")
if verify and len(objects) != 1:
raise click.BadParameter("verification requires a single object")
......
......@@ -38,7 +38,7 @@ class TestIdentify(DataMixin, unittest.TestCase):
"""identify file content"""
self.make_contents(self.tmpdir_name)
for _, content in self.contents.items():
result = self.runner.invoke(cli.identify, input=content["data"])
result = self.runner.invoke(cli.identify, ["-"], input=content["data"])
self.assertPidOK(result, "swh:1:cnt:" + hash_to_hex(content["sha1_git"]))
def test_directory_id(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment