|
37 | 37 |
|
38 | 38 | import typer |
39 | 39 | import httpx |
| 40 | +import importlib.metadata |
40 | 41 | from rich.console import Console |
41 | 42 | from rich.panel import Panel |
42 | 43 | from rich.progress import Progress, SpinnerColumn, TextColumn |
|
52 | 53 | import ssl |
53 | 54 | import truststore |
54 | 55 |
|
| 56 | +__version__ = importlib.metadata.version(__package__) |
55 | 57 | ssl_context = truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT) |
56 | 58 | client = httpx.Client(verify=ssl_context) |
57 | 59 |
|
@@ -373,9 +375,22 @@ def show_banner(): |
373 | 375 | console.print(Align.center(Text(TAGLINE, style="italic bright_yellow"))) |
374 | 376 | console.print() |
375 | 377 |
|
| 378 | +def show_version(): |
| 379 | + """Show the application version.""" |
| 380 | + typer.echo(f"{__package__} {__version__}") |
| 381 | + |
376 | 382 | @app.callback() |
377 | | -def callback(ctx: typer.Context): |
| 383 | +def callback( |
| 384 | + ctx: typer.Context, |
| 385 | + version: bool = typer.Option( |
| 386 | + None, "--version", help="Show version and exit.", is_eager=True |
| 387 | + ), |
| 388 | + ): |
378 | 389 | """Show banner when no subcommand is provided.""" |
| 390 | + if version: |
| 391 | + show_version() |
| 392 | + raise typer.Exit() |
| 393 | + |
379 | 394 | if ctx.invoked_subcommand is None and "--help" not in sys.argv and "-h" not in sys.argv: |
380 | 395 | show_banner() |
381 | 396 | console.print(Align.center("[dim]Run 'specify --help' for usage information[/dim]")) |
@@ -1118,6 +1133,11 @@ def check(): |
1118 | 1133 | if not any(agent_results.values()): |
1119 | 1134 | console.print("[dim]Tip: Install an AI assistant for the best experience[/dim]") |
1120 | 1135 |
|
| 1136 | +@app.command() |
| 1137 | +def version(): |
| 1138 | + """Show the application version.""" |
| 1139 | + show_version() |
| 1140 | + |
1121 | 1141 | def main(): |
1122 | 1142 | app() |
1123 | 1143 |
|
|
0 commit comments