Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/fastapi_cloud_cli/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from typing import Annotated

import typer
from rich import print

from . import __version__
from .commands.deploy import deploy
from .commands.env import env_app
from .commands.link import link
Expand All @@ -16,12 +20,34 @@

app = typer.Typer(rich_markup_mode="rich")


def version_callback(value: bool) -> None:
if value:
print(f"FastAPI Cloud CLI version: [green]{__version__}[/green]")
raise typer.Exit()


cloud_app = typer.Typer(
rich_markup_mode="rich",
help="Manage [bold]FastAPI[/bold] Cloud deployments. 🚀",
no_args_is_help=True,
)


@cloud_app.callback()
def cloud_main(
version: Annotated[
bool,
typer.Option(
"--version",
callback=version_callback,
is_eager=True,
help="Show the version and exit.",
),
] = False,
) -> None: ...


# TODO: use the app structure

# Additional commands
Expand Down
6 changes: 6 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ def test_script() -> None:
encoding="utf-8",
)
assert "Usage" in result.stdout


def test_version() -> None:
result = runner.invoke(app, ["cloud", "--version"])
assert result.exit_code == 0, result.output
assert "FastAPI Cloud CLI version:" in result.output
Loading