diff --git a/swh/model/cli.py b/swh/model/cli.py index 5b3969afb1485b6d2d14bc4361d016837fe1c5a4..ad7e2f5fe7e77e583a346d426d18b3bf7a305a42 100644 --- a/swh/model/cli.py +++ b/swh/model/cli.py @@ -159,7 +159,7 @@ def identify_object(obj_type, follow_symlinks, obj): type=PidParamType(), help="reference identifier to be compared with computed one", ) -@click.argument("objects", nargs=-1) +@click.argument("objects", nargs=-1, required=True) def identify(obj_type, verify, show_filename, follow_symlinks, objects): """Compute the Software Heritage persistent identifier (SWHID) for the given source code object(s). @@ -190,8 +190,6 @@ def identify(obj_type, verify, show_filename, follow_symlinks, objects): swh:1:snp:510aa88bdc517345d258c1fc2babcd0e1f905e93 helloworld.git """ # NoQA # overlong lines in shell examples are fine - if not 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 6c9c7517b4f77c6ee1a152a1599161bf0afdd8c5..21eb8c5c6cd573635f65bd4f3f011e8037c62016 100644 --- a/swh/model/tests/test_cli.py +++ b/swh/model/tests/test_cli.py @@ -26,6 +26,10 @@ class TestIdentify(DataMixin, unittest.TestCase): self.assertEqual(result.exit_code, 0) self.assertEqual(result.output.split()[0], pid) + def test_no_args(self): + result = self.runner.invoke(cli.identify) + self.assertNotEqual(result.exit_code, 0) + def test_content_id(self): """identify file content""" self.make_contents(self.tmpdir_name)