Skip to content

Commit

Permalink
Add -v/--version flag
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-Christophe Morin <[email protected]>
  • Loading branch information
JeanChristopheMorinPerso committed Apr 28, 2024
1 parent fc13150 commit 21d73bc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/rez_pip/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ def _createParser() -> argparse.ArgumentParser:
"-h", "--help", action="help", help="Show this help message and exit."
)

generalGroup.add_argument(
"-v",
"--version",
action="version",
version=importlib_metadata.version(__package__),
)

debugGroup = parser.add_argument_group(title="debug options")
debugGroup.add_argument(
"-l",
Expand Down
11 changes: 11 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import pytest
import rich.console
import packaging.version

import rez_pip.cli
import rez_pip.pip
Expand Down Expand Up @@ -114,6 +115,16 @@ def test_parseArgs_pipArgs():
assert pipArgs == ["adasdasd", "--requirement", "asd.txt"]


def test_version():
result = subprocess.run(
[sys.executable, "-m", "rez_pip", "--version"],
check=True,
stdout=subprocess.PIPE,
text=True,
)
assert packaging.version.parse(result.stdout.strip())


def test_validateArgs_pip_good(tmp_path: pathlib.Path):
path = pathlib.Path(tmp_path / "asd.pyz")

Expand Down

0 comments on commit 21d73bc

Please sign in to comment.