File tree Expand file tree Collapse file tree
src/fastapi_cloud_cli/commands/apps Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,7 +75,10 @@ def create_app(
7575 str | None ,
7676 typer .Option (
7777 "--directory" ,
78- help = "Directory containing the app's pyproject.toml." ,
78+ help = (
79+ "Relative app directory containing the pyproject.toml "
80+ "(for example: src or backend)."
81+ ),
7982 ),
8083 ] = None ,
8184 link : Annotated [
@@ -146,7 +149,17 @@ def create_app(
146149 )
147150 toolkit .print_line ()
148151
149- directory = validate_app_directory (directory )
152+ try :
153+ directory = validate_app_directory (directory )
154+ except ValueError as e :
155+ toolkit .fail (
156+ "invalid_input" ,
157+ f"Invalid app directory: { e } " ,
158+ hint = (
159+ "Pass a relative app directory such as `src` or `backend`; "
160+ "use --path with --link to choose a local filesystem path."
161+ ),
162+ )
150163
151164 with toolkit .progress (
152165 title = "Creating app" ,
Original file line number Diff line number Diff line change @@ -322,6 +322,36 @@ def test_creates_app_json_rejects_path_without_link(
322322 assert result .stderr == ""
323323
324324
325+ def test_creates_app_json_rejects_invalid_directory (logged_in_cli : None ) -> None :
326+ result = runner .invoke (
327+ app ,
328+ [
329+ "apps" ,
330+ "create" ,
331+ "--team-id" ,
332+ "00000000-0000-4000-8000-000000000001" ,
333+ "--name" ,
334+ "API" ,
335+ "--directory" ,
336+ "/tmp/api" ,
337+ "--json" ,
338+ ],
339+ )
340+
341+ assert result .exit_code == 1
342+ assert json .loads (result .stdout ) == {
343+ "error" : {
344+ "code" : "invalid_input" ,
345+ "message" : ("Invalid app directory: must be a relative path, not absolute" ),
346+ "hint" : (
347+ "Pass a relative app directory such as `src` or `backend`; "
348+ "use --path with --link to choose a local filesystem path."
349+ ),
350+ }
351+ }
352+ assert result .stderr == ""
353+
354+
325355@pytest .mark .respx
326356def test_links_existing_app_to_path_as_json (
327357 logged_in_cli : None ,
You can’t perform that action at this time.
0 commit comments