Skip to content

Commit 3188b73

Browse files
authored
Merge pull request #60 from nexB/version
Add --version option
2 parents 1094163 + b0eca14 commit 3188b73

File tree

9 files changed

+30
-8
lines changed

9 files changed

+30
-8
lines changed

src/python_inspector/resolve_cli.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,19 @@
3131

3232
TRACE = False
3333

34-
__version__ = "0.6.3"
34+
__version__ = "0.6.4"
3535

3636
DEFAULT_PYTHON_VERSION = "38"
3737
PYPI_SIMPLE_URL = "https://pypi.org/simple"
3838

3939

40+
def print_version(ctx, param, value):
41+
if not value or ctx.resilient_parsing:
42+
return
43+
click.echo(f"Python-inspector version: {__version__}")
44+
ctx.exit()
45+
46+
4047
@click.command()
4148
@click.pass_context
4249
@click.option(
@@ -155,6 +162,15 @@
155162
hidden=True,
156163
help="Enable debug output.",
157164
)
165+
@click.option(
166+
"-V",
167+
"--version",
168+
is_flag=True,
169+
is_eager=True,
170+
expose_value=False,
171+
callback=print_version,
172+
help="Show the version and exit.",
173+
)
158174
@click.help_option("-h", "--help")
159175
def resolve_dependencies(
160176
ctx,

tests/data/default-url-expected.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"headers": {
33
"tool_name": "python-inspector",
44
"tool_homepageurl": "https://github.com/nexB/python-inspector",
5-
"tool_version": "0.6.3",
5+
"tool_version": "0.6.4",
66
"options": [
77
"--specifier zipp==3.8.0",
88
"--index-url https://pypi.org/simple",

tests/data/pinned-requirements.txt-expected.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"headers": {
33
"tool_name": "python-inspector",
44
"tool_homepageurl": "https://github.com/nexB/python-inspector",
5-
"tool_version": "0.6.3",
5+
"tool_version": "0.6.4",
66
"options": [
77
"--index-url https://pypi.org/simple",
88
"--python-version 38",

tests/data/setup/simple-setup.py-expected.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"headers": {
33
"tool_name": "python-inspector",
44
"tool_homepageurl": "https://github.com/nexB/python-inspector",
5-
"tool_version": "0.6.3",
5+
"tool_version": "0.6.4",
66
"options": [
77
"--index-url https://pypi.org/simple",
88
"--python-version 27",

tests/data/single-url-except-simple-expected.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"headers": {
33
"tool_name": "python-inspector",
44
"tool_homepageurl": "https://github.com/nexB/python-inspector",
5-
"tool_version": "0.6.3",
5+
"tool_version": "0.6.4",
66
"options": [
77
"--specifier flask",
88
"--index-url https://pypi.org/simple",

tests/data/single-url-expected.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"headers": {
33
"tool_name": "python-inspector",
44
"tool_homepageurl": "https://github.com/nexB/python-inspector",
5-
"tool_version": "0.6.3",
5+
"tool_version": "0.6.4",
66
"options": [
77
"--specifier zipp==3.8.0",
88
"--index-url https://pypi.org/simple",

tests/data/tilde_req-expected.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"headers": {
33
"tool_name": "python-inspector",
44
"tool_homepageurl": "https://github.com/nexB/python-inspector",
5-
"tool_version": "0.6.3",
5+
"tool_version": "0.6.4",
66
"options": [
77
"--specifier zipp~=3.8.0",
88
"--index-url https://pypi.org/simple",

tests/test_cli.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,12 @@ def test_passing_of_json_pdt_and_json_flags():
262262
run_cli(options=options, expected_rc=1)
263263

264264

265+
def test_version_option():
266+
options = ["--version"]
267+
result = run_cli(options=options)
268+
assert "0.6.4" in result.output
269+
270+
265271
def test_passing_of_netrc_file_that_does_not_exist():
266272
options = ["--specifier", "foo", "--netrc", "bar.txt", "--json", "-"]
267273
run_cli(options=options, expected_rc=2)

tests/test_resolution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def test_without_supported_wheels():
145145
"pkg:pypi/hyperlink@21.0.0",
146146
"pkg:pypi/idna@3.3",
147147
"pkg:pypi/pycparser@2.21",
148-
"pkg:pypi/setuptools@65.2.0",
148+
"pkg:pypi/setuptools@65.3.0",
149149
"pkg:pypi/txaio@22.2.1",
150150
]
151151

0 commit comments

Comments
 (0)