Update version flag (#1452)

This commit is contained in:
Nikhil Rao 2023-07-28 12:30:39 -07:00 committed by GitHub
parent 6bc622e67d
commit 0ebe1529a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 8 deletions

View File

@ -66,7 +66,7 @@ pre-commit = {version = "^3.2.1", python = ">=3.8,<4.0"}
selenium = "^4.10.0"
[tool.poetry.scripts]
reflex = "reflex.reflex:main"
reflex = "reflex.reflex:cli"
[build-system]
requires = ["poetry-core>=1.5.1"]

View File

@ -18,10 +18,33 @@ from reflex.utils import build, console, exec, prerequisites, processes, telemet
cli = typer.Typer()
@cli.command()
def version():
"""Get the Reflex version."""
console.print(constants.VERSION)
def version(value: bool):
"""Get the Reflex version.
Args:
value: Whether the version flag was passed.
Raises:
typer.Exit: If the version flag was passed.
"""
if value:
console.print(constants.VERSION)
raise typer.Exit()
@cli.callback()
def main(
version: bool = typer.Option(
None,
"--version",
"-v",
callback=version,
help="Get the Reflex version.",
is_eager=True,
),
):
"""Reflex CLI global configuration."""
pass
@cli.command()
@ -306,8 +329,7 @@ def makemigrations(
)
cli.add_typer(db_cli, name="db", help="Subcommands for managing the database schema")
main = cli
cli.add_typer(db_cli, name="db", help="Subcommands for managing the database schema.")
if __name__ == "__main__":
main()
cli()