Skip to content

Commit 5c196ae

Browse files
committed
Add --version option
Signed-off-by: Tushar Goel <[email protected]>
1 parent 1094163 commit 5c196ae

File tree

3 files changed

+63
-1
lines changed

3 files changed

+63
-1
lines changed

ort-setup-py.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[
2+
{
3+
"key": "ply",
4+
"package_name": "ply",
5+
"installed_version": "3.11",
6+
"dependencies": []
7+
},
8+
{
9+
"key": "rdflib",
10+
"package_name": "rdflib",
11+
"installed_version": "6.2.0",
12+
"dependencies": [
13+
{
14+
"key": "isodate",
15+
"package_name": "isodate",
16+
"installed_version": "0.6.1",
17+
"dependencies": [
18+
{
19+
"key": "six",
20+
"package_name": "six",
21+
"installed_version": "1.16.0",
22+
"dependencies": []
23+
}
24+
]
25+
},
26+
{
27+
"key": "pyparsing",
28+
"package_name": "pyparsing",
29+
"installed_version": "3.0.9",
30+
"dependencies": []
31+
},
32+
{
33+
"key": "setuptools",
34+
"package_name": "setuptools",
35+
"installed_version": "65.2.0",
36+
"dependencies": []
37+
}
38+
]
39+
}
40+
]

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/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 result.output == "0.6.4"
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)

0 commit comments

Comments
 (0)