File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ from typing import Annotated
2+
13import typer
4+ from rich import print
25
6+ from . import __version__
37from .commands .deploy import deploy
48from .commands .env import env_app
59from .commands .link import link
1620
1721app = typer .Typer (rich_markup_mode = "rich" )
1822
23+
24+ def version_callback (value : bool ) -> None :
25+ if value :
26+ print (f"FastAPI Cloud CLI version: [green]{ __version__ } [/green]" )
27+ raise typer .Exit ()
28+
29+
1930cloud_app = typer .Typer (
2031 rich_markup_mode = "rich" ,
2132 help = "Manage [bold]FastAPI[/bold] Cloud deployments. 🚀" ,
2233)
2334
35+
36+ @cloud_app .callback ()
37+ def cloud_main (
38+ version : Annotated [
39+ bool ,
40+ typer .Option (
41+ "--version" ,
42+ callback = version_callback ,
43+ is_eager = True ,
44+ help = "Show the version and exit." ,
45+ ),
46+ ] = False ,
47+ ) -> None : ...
48+
49+
2450# TODO: use the app structure
2551
2652# Additional commands
Original file line number Diff line number Diff line change 11import subprocess
22import sys
33
4+ from typer .testing import CliRunner
5+
6+ from fastapi_cloud_cli .cli import cloud_app as app
7+
8+ runner = CliRunner ()
9+
410
511def test_script () -> None :
612 result = subprocess .run (
@@ -9,3 +15,9 @@ def test_script() -> None:
915 encoding = "utf-8" ,
1016 )
1117 assert "Usage" in result .stdout
18+
19+
20+ def test_version () -> None :
21+ result = runner .invoke (app , ["--version" ])
22+ assert result .exit_code == 0 , result .output
23+ assert "FastAPI Cloud CLI version:" in result .output
You can’t perform that action at this time.
0 commit comments