forked from Github-Mirrors/canaille
Merge branch 'version' into 'main'
--version CLI option See merge request yaal/canaille!209
This commit is contained in:
commit
7bc3c05cdd
3 changed files with 27 additions and 0 deletions
|
@ -1,3 +1,10 @@
|
|||
[0.0.58] - Unreleased
|
||||
---------------------
|
||||
|
||||
Added
|
||||
^^^^^
|
||||
- ``--version`` option to the CLI. :pr:`209`
|
||||
|
||||
[0.0.57] - 2024-12-31
|
||||
---------------------
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import importlib.metadata
|
||||
|
||||
import click
|
||||
from flask.cli import FlaskGroup
|
||||
|
||||
|
@ -7,6 +9,8 @@ import canaille.core.commands
|
|||
import canaille.oidc.commands
|
||||
from canaille import create_app
|
||||
|
||||
version = importlib.metadata.version("canaille")
|
||||
|
||||
|
||||
@click.group(
|
||||
cls=FlaskGroup,
|
||||
|
@ -14,6 +18,7 @@ from canaille import create_app
|
|||
add_version_option=False,
|
||||
add_default_commands=False,
|
||||
)
|
||||
@click.version_option(version, prog_name="Canaille")
|
||||
def cli():
|
||||
"""Canaille management utilities."""
|
||||
|
||||
|
@ -22,3 +27,7 @@ canaille.app.commands.register(cli)
|
|||
canaille.backends.commands.register(cli)
|
||||
canaille.core.commands.register(cli)
|
||||
canaille.oidc.commands.register(cli)
|
||||
|
||||
|
||||
if __name__ == "__main__": # pragma: no cover
|
||||
cli()
|
||||
|
|
11
tests/app/commands/test_version.py
Normal file
11
tests/app/commands/test_version.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
import re
|
||||
|
||||
from canaille.commands import cli
|
||||
|
||||
|
||||
def test_check_command(testclient, mock_smpp):
|
||||
runner = testclient.app.test_cli_runner()
|
||||
res = runner.invoke(cli, ["--version"])
|
||||
semver_pattern = r"(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?"
|
||||
assert re.match(rf"Canaille, version {semver_pattern}", res.stdout)
|
||||
assert res.exit_code == 0, res.stdout
|
Loading…
Reference in a new issue