From c34625ba73a1e55321297654a95dc4ed6c027940 Mon Sep 17 00:00:00 2001 From: Moritz Marseu Date: Mon, 26 Aug 2024 18:04:55 +0200 Subject: [PATCH] fix: set `--version` cannot be combined with `--version-range` (#218) --- cdxev/__main__.py | 6 ++++-- tests/integration/test_integration.py | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cdxev/__main__.py b/cdxev/__main__.py index 592d4205..9ae76964 100644 --- a/cdxev/__main__.py +++ b/cdxev/__main__.py @@ -604,12 +604,14 @@ def create_set_parser( metavar="", help="Group of target component. If specified, name must also be specified.", ) - identifiers.add_argument( + + group = identifiers.add_mutually_exclusive_group() + group.add_argument( "--version", metavar="", help="Version of target component. If specified, name must also be specified.", ) - identifiers.add_argument( + group.add_argument( "--version-range", metavar="", help="Version range of target components. If specified, name must also be specified.", diff --git a/tests/integration/test_integration.py b/tests/integration/test_integration.py index b3cb2551..7402c56f 100644 --- a/tests/integration/test_integration.py +++ b/tests/integration/test_integration.py @@ -546,13 +546,14 @@ def test_from_file( ["purl", "swid", "key", "value"], ["name", "cpe", "key", "value"], ["version", "group", "key", "value"], + ["name", "version", "version-range", "key", "value"], ["key", "value"], ["name", "key"], ["name", "value"], ["from-file", "name"], ["from-file", "key", "value"], ], - ids=lambda keys: "only: " + ", ".join(keys), + ids=lambda keys: "options: " + ", ".join(keys), ) def test_invalid_option_combinations( self, use_only: list[str], input_file: Path, argv: Callable[..., None] @@ -560,6 +561,7 @@ def test_invalid_option_combinations( options = { "name": "comp", "version": "1.0.0", + "version-range": "vers:generic/>1.0.0", "group": "acme", "purl": "pkg:test/comp@1.0.0", "swid": "foo",