From b5001358440fc32fecb6ff8f969719441142f942 Mon Sep 17 00:00:00 2001 From: Hai Lang Date: Wed, 10 Jun 2026 10:55:09 +0700 Subject: [PATCH] feat: have option to show version Forge ID: F#T67843 --- trobz_deploy/cli.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/trobz_deploy/cli.py b/trobz_deploy/cli.py index 3235eec..c4e787e 100644 --- a/trobz_deploy/cli.py +++ b/trobz_deploy/cli.py @@ -1,5 +1,6 @@ from __future__ import annotations +from importlib.metadata import version from typing import Annotated import typer @@ -12,9 +13,25 @@ app = typer.Typer(help="Deploy and manage applications on remote servers over SSH.") +def version_callback(value: bool): + if value: + typer.echo(f"trobz-deploy {version('trobz-deploy')}") + raise typer.Exit() + + @app.callback() def cli( ctx: typer.Context, + version: Annotated[ + bool, + typer.Option( + "--version", + "-V", + callback=version_callback, + is_eager=True, + help="Display the trobz-deploy version.", + ), + ] = False, config: Annotated[ str, typer.Option(show_default=True, metavar="FILE", help="Path to the configuration file."),