Skip to content

Commit ea81ee5

Browse files
committed
Add --version flag to CLI
1 parent f4d8a5e commit ea81ee5

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

sidemantic/cli.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from pathlib import Path
44

55
import typer
6+
7+
from sidemantic import __version__
68
from textual import events
79
from textual.app import App, ComposeResult
810
from textual.binding import Binding
@@ -21,8 +23,21 @@
2123
"Custom": "-- Write your custom query here\nSELECT \n \nFROM ",
2224
}
2325

26+
def version_callback(value: bool):
27+
"""Print version and exit."""
28+
if value:
29+
typer.echo(f"sidemantic {__version__}")
30+
raise typer.Exit()
31+
2432
app = typer.Typer(help="Sidemantic: SQL-first semantic layer")
2533

34+
@app.callback()
35+
def main(
36+
version: bool = typer.Option(None, "--version", "-v", callback=version_callback, is_eager=True, help="Show version"),
37+
):
38+
"""Sidemantic CLI."""
39+
pass
40+
2641

2742
class SidequeryWorkbench(App):
2843
"""Sidequery Workbench - Interactive semantic layer workbench."""

0 commit comments

Comments
 (0)