diff --git a/swh/model/cli.py b/swh/model/cli.py index 3947d826b9eb7243c848b6fc4117fafa6e3a2e2b..5b3969afb1485b6d2d14bc4361d016837fe1c5a4 100644 --- a/swh/model/cli.py +++ b/swh/model/cli.py @@ -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") diff --git a/swh/model/tests/test_cli.py b/swh/model/tests/test_cli.py index fac1d89d7b414b395d876ea0e57f7090ea197050..6c9c7517b4f77c6ee1a152a1599161bf0afdd8c5 100644 --- a/swh/model/tests/test_cli.py +++ b/swh/model/tests/test_cli.py @@ -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):