Add -v --version option to display version
This commit is contained in:
parent
d677dc8001
commit
8052442052
1 changed files with 17 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from importlib.metadata import version
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import typer
|
import typer
|
||||||
|
|
@ -26,8 +27,23 @@ async def check_version():
|
||||||
console.print("[yellow]Please update.[/yellow]")
|
console.print("[yellow]Please update.[/yellow]")
|
||||||
|
|
||||||
|
|
||||||
|
def version_callback(value: bool):
|
||||||
|
if value:
|
||||||
|
v = version("haiku.rag")
|
||||||
|
console.print(f"haiku.rag version {v}")
|
||||||
|
raise typer.Exit()
|
||||||
|
|
||||||
|
|
||||||
@cli.callback()
|
@cli.callback()
|
||||||
def main():
|
def main(
|
||||||
|
_version: bool = typer.Option(
|
||||||
|
False,
|
||||||
|
"-v",
|
||||||
|
"--version",
|
||||||
|
callback=version_callback,
|
||||||
|
help="Show version and exit",
|
||||||
|
),
|
||||||
|
):
|
||||||
"""haiku.rag CLI - SQLite-based RAG system"""
|
"""haiku.rag CLI - SQLite-based RAG system"""
|
||||||
# Run version check before any command
|
# Run version check before any command
|
||||||
event_loop.run_until_complete(check_version())
|
event_loop.run_until_complete(check_version())
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue