Add arcade --version (#211)
# PR Description Implements a version callback for the arcade CLI. ### Usage `arcade --version` OR `arcade -v` ### Example Output `Arcade (version 0.1.5)`
This commit is contained in:
parent
830f6f9f90
commit
7a7f37e5fc
2 changed files with 25 additions and 0 deletions
|
|
@ -36,6 +36,7 @@ from arcade.cli.utils import (
|
|||
load_eval_suites,
|
||||
log_engine_health,
|
||||
validate_and_get_config,
|
||||
version_callback,
|
||||
)
|
||||
|
||||
cli = typer.Typer(
|
||||
|
|
@ -475,3 +476,17 @@ def workerup(
|
|||
error_message = f"❌ Failed to start Arcade Worker: {escape(str(e))}"
|
||||
console.print(error_message, style="bold red")
|
||||
typer.Exit(code=1)
|
||||
|
||||
|
||||
@cli.callback()
|
||||
def version(
|
||||
_: bool = typer.Option(
|
||||
None,
|
||||
"-v",
|
||||
"--version",
|
||||
callback=version_callback,
|
||||
is_eager=True,
|
||||
help="Print version and exit.",
|
||||
),
|
||||
) -> None:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -667,3 +667,13 @@ def parse_user_command(user_input: str) -> ChatCommand | None:
|
|||
return ChatCommand(user_input)
|
||||
except ValueError:
|
||||
return None
|
||||
|
||||
|
||||
def version_callback(value: bool) -> None:
|
||||
"""Callback implementation for the `arcade --version`.
|
||||
Prints the version of Arcade and exit.
|
||||
"""
|
||||
if value:
|
||||
version = importlib.import_module("arcade").__version__
|
||||
console.print(f"[bold]Arcade[/bold] (version {version})")
|
||||
exit()
|
||||
|
|
|
|||
Loading…
Reference in a new issue