Skip to content

Commit

Permalink
fix: set --version cannot be combined with --version-range (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarseu authored Aug 26, 2024
1 parent 59bff0a commit c34625b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions cdxev/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,12 +604,14 @@ def create_set_parser(
metavar="<group>",
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="<version>",
help="Version of target component. If specified, name must also be specified.",
)
identifiers.add_argument(
group.add_argument(
"--version-range",
metavar="<version>",
help="Version range of target components. If specified, name must also be specified.",
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,20 +546,22 @@ 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]
):
options = {
"name": "comp",
"version": "1.0.0",
"version-range": "vers:generic/>1.0.0",
"group": "acme",
"purl": "pkg:test/[email protected]",
"swid": "foo",
Expand Down

0 comments on commit c34625b

Please sign in to comment.