Skip to content

Commit 6110af1

Browse files
committed
refactor: remove the short version flag
1 parent b6b1461 commit 6110af1

9 files changed

Lines changed: 11 additions & 16 deletions

File tree

changelog.d/+fedb3a15.removed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove the short version flag `-V` for all command-line interfaces.

template/src/{{ package_name }}/{% if cli == 'argparse' %}.{% endif %}/cli.py.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def create_parser() -> argparse.ArgumentParser:
2222
description="run the main program",
2323
)
2424
parser.add_argument(
25-
"--version", "-V", action="version", version="%(prog)s " + __version__
25+
"--version", action="version", version=f"%(prog)s {__version__}"
2626
)
2727
return parser
2828

template/src/{{ package_name }}/{% if cli == 'click' %}.{% endif %}/cli.py.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ from . import __version__
99

1010
@click.command()
1111
@click.help_option("--help", "-h")
12-
@click.version_option(__version__, "--version", "-V")
12+
@click.version_option()
1313
def main() -> None:
1414
"""Run the main program."""
1515
return

template/src/{{ package_name }}/{% if cli == 'cyclopts' %}.{% endif %}/cli.py.jinja

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ from . import __version__
99
app = cyclopts.App(
1010
help="Run the main program.",
1111
version=f"{{ distribution_name }}, version {__version__}",
12-
version_flags=("--version", "-V"),
1312
)
1413

1514

template/src/{{ package_name }}/{% if cli == 'typer' %}.{% endif %}/cli.py.jinja

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ def main(
2828
bool,
2929
typer.Option(
3030
"--version",
31-
"-V",
3231
callback=show_version,
3332
is_eager=True,
3433
help="Show the version and exit.",

template/tests/{% if cli == 'argparse' %}test_cli.py{% endif %}.jinja

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ def test_show_help(option: str) -> None:
2222
assert excinfo.value.code == 0
2323

2424

25-
@pytest.mark.parametrize("option", ["--version", "-V"])
26-
def test_show_version(option: str, capsys: pytest.CaptureFixture[str]) -> None:
25+
def test_show_version(capsys: pytest.CaptureFixture[str]) -> None:
2726
"""Test the version option of the command-line interface."""
2827
with pytest.raises(SystemExit) as excinfo:
29-
main([option])
28+
main(["--version"])
3029

3130
assert excinfo.value.code == 0
3231

template/tests/{% if cli == 'click' %}test_cli.py{% endif %}.jinja

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ def test_show_help(option: str) -> None:
2424
assert result.exit_code == 0
2525

2626

27-
@pytest.mark.parametrize("option", ["--version", "-V"])
28-
def test_show_version(option: str) -> None:
27+
def test_show_version() -> None:
2928
"""Test the version option of the command-line interface."""
3029
runner = CliRunner()
31-
result = runner.invoke(main, [option])
30+
result = runner.invoke(main, ["--version"])
3231
assert result.exit_code == 0
3332
assert __version__ in result.stdout

template/tests/{% if cli == 'cyclopts' %}test_cli.py{% endif %}.jinja

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ def test_show_help(option: str) -> None:
2121
assert result is None
2222

2323

24-
@pytest.mark.parametrize("option", ["--version", "-V"])
25-
def test_show_version(option: str, capsys: pytest.CaptureFixture[str]) -> None:
24+
def test_show_version(capsys: pytest.CaptureFixture[str]) -> None:
2625
"""Test the version option of the command-line interface."""
27-
result = app([option])
26+
result = app(["--version"])
2827
assert result is None
2928

3029
captured = capsys.readouterr()

template/tests/{% if cli == 'typer' %}test_cli.py{% endif %}.jinja

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ def test_show_help(option: str) -> None:
2424
assert result.exit_code == 0
2525

2626

27-
@pytest.mark.parametrize("option", ["--version", "-V"])
28-
def test_show_version(option: str) -> None:
27+
def test_show_version() -> None:
2928
"""Test the version option of the command-line interface."""
3029
runner = CliRunner()
31-
result = runner.invoke(app, [option])
30+
result = runner.invoke(app, ["--version"])
3231
assert result.exit_code == 0
3332
assert __version__ in result.stdout

0 commit comments

Comments
 (0)