diff --git a/src/python_inspector/resolve_cli.py b/src/python_inspector/resolve_cli.py index b9013a55..8081effd 100644 --- a/src/python_inspector/resolve_cli.py +++ b/src/python_inspector/resolve_cli.py @@ -31,12 +31,19 @@ TRACE = False -__version__ = "0.6.3" +__version__ = "0.6.4" DEFAULT_PYTHON_VERSION = "38" PYPI_SIMPLE_URL = "https://pypi.org/simple" +def print_version(ctx, param, value): + if not value or ctx.resilient_parsing: + return + click.echo(f"Python-inspector version: {__version__}") + ctx.exit() + + @click.command() @click.pass_context @click.option( @@ -155,6 +162,15 @@ hidden=True, help="Enable debug output.", ) +@click.option( + "-V", + "--version", + is_flag=True, + is_eager=True, + expose_value=False, + callback=print_version, + help="Show the version and exit.", +) @click.help_option("-h", "--help") def resolve_dependencies( ctx, diff --git a/tests/data/default-url-expected.json b/tests/data/default-url-expected.json index f83b36ed..3c76d875 100644 --- a/tests/data/default-url-expected.json +++ b/tests/data/default-url-expected.json @@ -2,7 +2,7 @@ "headers": { "tool_name": "python-inspector", "tool_homepageurl": "https://github.com/nexB/python-inspector", - "tool_version": "0.6.3", + "tool_version": "0.6.4", "options": [ "--specifier zipp==3.8.0", "--index-url https://pypi.org/simple", diff --git a/tests/data/pinned-requirements.txt-expected.json b/tests/data/pinned-requirements.txt-expected.json index c10bcae9..c062b454 100644 --- a/tests/data/pinned-requirements.txt-expected.json +++ b/tests/data/pinned-requirements.txt-expected.json @@ -2,7 +2,7 @@ "headers": { "tool_name": "python-inspector", "tool_homepageurl": "https://github.com/nexB/python-inspector", - "tool_version": "0.6.3", + "tool_version": "0.6.4", "options": [ "--index-url https://pypi.org/simple", "--python-version 38", diff --git a/tests/data/setup/simple-setup.py-expected.json b/tests/data/setup/simple-setup.py-expected.json index dbc91309..c98e78e4 100644 --- a/tests/data/setup/simple-setup.py-expected.json +++ b/tests/data/setup/simple-setup.py-expected.json @@ -2,7 +2,7 @@ "headers": { "tool_name": "python-inspector", "tool_homepageurl": "https://github.com/nexB/python-inspector", - "tool_version": "0.6.3", + "tool_version": "0.6.4", "options": [ "--index-url https://pypi.org/simple", "--python-version 27", diff --git a/tests/data/single-url-except-simple-expected.json b/tests/data/single-url-except-simple-expected.json index dd9809e0..fb8a3af9 100644 --- a/tests/data/single-url-except-simple-expected.json +++ b/tests/data/single-url-except-simple-expected.json @@ -2,7 +2,7 @@ "headers": { "tool_name": "python-inspector", "tool_homepageurl": "https://github.com/nexB/python-inspector", - "tool_version": "0.6.3", + "tool_version": "0.6.4", "options": [ "--specifier flask", "--index-url https://pypi.org/simple", diff --git a/tests/data/single-url-expected.json b/tests/data/single-url-expected.json index e72bcb25..1ee1150a 100644 --- a/tests/data/single-url-expected.json +++ b/tests/data/single-url-expected.json @@ -2,7 +2,7 @@ "headers": { "tool_name": "python-inspector", "tool_homepageurl": "https://github.com/nexB/python-inspector", - "tool_version": "0.6.3", + "tool_version": "0.6.4", "options": [ "--specifier zipp==3.8.0", "--index-url https://pypi.org/simple", diff --git a/tests/data/tilde_req-expected.json b/tests/data/tilde_req-expected.json index 47c58853..0eab59a1 100644 --- a/tests/data/tilde_req-expected.json +++ b/tests/data/tilde_req-expected.json @@ -2,7 +2,7 @@ "headers": { "tool_name": "python-inspector", "tool_homepageurl": "https://github.com/nexB/python-inspector", - "tool_version": "0.6.3", + "tool_version": "0.6.4", "options": [ "--specifier zipp~=3.8.0", "--index-url https://pypi.org/simple", diff --git a/tests/test_cli.py b/tests/test_cli.py index 94c4095f..26ed3b23 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -262,6 +262,12 @@ def test_passing_of_json_pdt_and_json_flags(): run_cli(options=options, expected_rc=1) +def test_version_option(): + options = ["--version"] + result = run_cli(options=options) + assert "0.6.4" in result.output + + def test_passing_of_netrc_file_that_does_not_exist(): options = ["--specifier", "foo", "--netrc", "bar.txt", "--json", "-"] run_cli(options=options, expected_rc=2) diff --git a/tests/test_resolution.py b/tests/test_resolution.py index 3235e6a0..d4938ed4 100644 --- a/tests/test_resolution.py +++ b/tests/test_resolution.py @@ -145,7 +145,7 @@ def test_without_supported_wheels(): "pkg:pypi/hyperlink@21.0.0", "pkg:pypi/idna@3.3", "pkg:pypi/pycparser@2.21", - "pkg:pypi/setuptools@65.2.0", + "pkg:pypi/setuptools@65.3.0", "pkg:pypi/txaio@22.2.1", ]