Add CLI entry point with version command
This commit is contained in:
40
src/py_dvt_ate/cli/main.py
Normal file
40
src/py_dvt_ate/cli/main.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
"""Command-line interface for py_dvt_ate."""
|
||||||
|
|
||||||
|
from typing import Annotated, Optional
|
||||||
|
|
||||||
|
import typer
|
||||||
|
|
||||||
|
from py_dvt_ate import __version__
|
||||||
|
|
||||||
|
app = typer.Typer(
|
||||||
|
name="py-dvt-ate",
|
||||||
|
help="Coupled Physics DVT Simulation Platform",
|
||||||
|
add_completion=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def version_callback(value: bool) -> None:
|
||||||
|
"""Print version and exit."""
|
||||||
|
if value:
|
||||||
|
typer.echo(f"py-dvt-ate version {__version__}")
|
||||||
|
raise typer.Exit()
|
||||||
|
|
||||||
|
|
||||||
|
@app.callback()
|
||||||
|
def main(
|
||||||
|
version: Annotated[
|
||||||
|
Optional[bool],
|
||||||
|
typer.Option(
|
||||||
|
"--version",
|
||||||
|
"-v",
|
||||||
|
help="Show version and exit.",
|
||||||
|
callback=version_callback,
|
||||||
|
is_eager=True,
|
||||||
|
),
|
||||||
|
] = None,
|
||||||
|
) -> None:
|
||||||
|
"""py-dvt-ate: Coupled Physics DVT Simulation Platform."""
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app()
|
||||||
Reference in New Issue
Block a user