Skip to content

Commit 4acfa59

Browse files
committed
[FIX] applying formatting & abstract cli startproject describing
1 parent 6d091b8 commit 4acfa59

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

src/fastapi_fastkit/cli.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def echo(ctx: Context) -> None:
9494

9595

9696
@fastkit_cli.command()
97-
def list() -> None:
97+
def list_templates() -> None:
9898
# TODO : impl this
9999
"""
100100
Get available templates list.
@@ -191,7 +191,7 @@ def startup(
191191

192192
@fastkit_cli.command(context_settings={"ignore_unknown_options": True})
193193
def startproject() -> None:
194-
# TODO : impl this, add a stack selecting process?
194+
# TODO : impl this. this method includes a stack selecting process. when user select a stack, it will be auto installed at venv environment, and make list of installed dependencies at requirements.txt file.
195195
"""
196196
Start a empty FastAPI project.
197197
:return:
@@ -251,7 +251,9 @@ def deleteproject(ctx: Context, project_name: str) -> None:
251251
help="Enable or disable auto-reloading on code changes.",
252252
)
253253
@click.pass_context
254-
def runserver(ctx: Context, host: str = '127.0.0.1', port: int = 8000, reload: bool = True) -> None:
254+
def runserver(
255+
ctx: Context, host: str = "127.0.0.1", port: int = 8000, reload: bool = True
256+
) -> None:
255257
# TODO : add & apply click option
256258
# TODO : edit template 'fastapi-default'. fix modules
257259
"""
@@ -268,15 +270,13 @@ def runserver(ctx: Context, host: str = '127.0.0.1', port: int = 8000, reload: b
268270

269271
app_path = os.path.join(project_dir, "main.py")
270272
if not os.path.exists(app_path):
271-
click.echo(f"Error: No 'main.py' found in the project directory '{project_dir}'.")
273+
click.echo(
274+
f"Error: No 'main.py' found in the project directory '{project_dir}'."
275+
)
272276
return
273277

274278
# TODO : edit this - add click's params
275-
command = [
276-
"fastapi",
277-
"dev",
278-
"main.py"
279-
]
279+
command = ["fastapi", "dev", "main.py"]
280280

281281
try:
282282
click.echo(f"Starting FastAPI server at {host}:{port}...")

tests/test_cli_operations/test_cli.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ def test_startup(self, temp_dir) -> None:
5858
)
5959

6060
# then
61-
project_path = (
62-
Path(temp_dir) / "test-project"
63-
)
61+
project_path = Path(temp_dir) / "test-project"
6462
assert project_path.exists() and project_path.is_dir()
6563
assert (
6664
f"FastAPI project 'test-project' from 'fastapi-default' has been created and saved to {temp_dir}!"
@@ -97,13 +95,11 @@ def test_deleteproject(self, temp_dir) -> None:
9795
[project_name, "bnbong", "bbbong9@gmail.com", "test project", "Y"]
9896
),
9997
)
100-
project_path = (
101-
Path(temp_dir) / project_name
102-
)
98+
project_path = Path(temp_dir) / project_name
10399
assert project_path.exists() and project_path.is_dir()
104100
assert (
105-
f"FastAPI project '{project_name}' from 'fastapi-default' has been created and saved to {temp_dir}!"
106-
in result.output
101+
f"FastAPI project '{project_name}' from 'fastapi-default' has been created and saved to {temp_dir}!"
102+
in result.output
107103
)
108104

109105
expected_files = ["main.py", "setup.py"]
@@ -119,5 +115,7 @@ def test_deleteproject(self, temp_dir) -> None:
119115
)
120116

121117
# then
122-
assert f"Project '{project_name}' has been successfully deleted" in result.output
118+
assert (
119+
f"Project '{project_name}' has been successfully deleted" in result.output
120+
)
123121
assert not project_path.exists()

0 commit comments

Comments
 (0)