33from __future__ import annotations
44
55import os
6+ import shutil
67import subprocess
78import sys
89from pathlib import Path
@@ -65,7 +66,7 @@ def info() -> None:
6566
6667@server_app .command ("start" )
6768def server_start (
68- host : str = typer .Option ("0 .0.0.0 " , "--host" , help = "Host to bind" ),
69+ host : str = typer .Option ("127 .0.0.1 " , "--host" , help = "Host to bind" ),
6970 port : int = typer .Option (8913 , "--port" , "-p" , help = "Port to bind" ),
7071 reload : bool = typer .Option (False , "--reload/--no-reload" , help = "Enable autoreload" ),
7172 ssl : bool = typer .Option (True , "--ssl/--no-ssl" , help = "Serve over HTTPS" ),
@@ -96,7 +97,9 @@ def db_build(
9697 cluster : str = typer .Option ("" , "--cluster" , help = "Aurora cluster ID for aurora target" ),
9798 profile : str = typer .Option (DEFAULT_AWS_PROFILE , "--profile" , help = "AWS profile" ),
9899 region : str = typer .Option (DEFAULT_AWS_REGION , "--region" , help = "AWS region" ),
99- namespace : str = typer .Option (DEFAULT_TAPDB_DATABASE_NAME , "--namespace" , help = "TapDB namespace" ),
100+ namespace : str = typer .Option (
101+ DEFAULT_TAPDB_DATABASE_NAME , "--namespace" , help = "TapDB namespace"
102+ ),
100103) -> None :
101104 """Bootstrap TapDB runtime and apply Dewey overlay."""
102105 ensure_tapdb_version ()
@@ -115,7 +118,15 @@ def db_build(
115118 if not cluster .strip ():
116119 raise TapDBRuntimeError ("--cluster is required for aurora target" )
117120 result = run_tapdb_cli (
118- ["bootstrap" , "aurora" , "--cluster" , cluster .strip (), "--region" , region , "--no-gui" ],
121+ [
122+ "bootstrap" ,
123+ "aurora" ,
124+ "--cluster" ,
125+ cluster .strip (),
126+ "--region" ,
127+ region ,
128+ "--no-gui" ,
129+ ],
119130 target = target ,
120131 client_id = DEFAULT_TAPDB_CLIENT_ID ,
121132 profile = profile ,
@@ -135,7 +146,9 @@ def db_build(
135146 console .print (f"[green]DATABASE_URL[/green] resolved: [dim]{ db_url } [/dim]" )
136147
137148 # Overlay step: bootstrap Dewey templates through app service.
138- subprocess .run ([sys .executable , "-m" , "dewey_service.db_seed" ], cwd = PROJECT_ROOT , check = True )
149+ subprocess .run (
150+ [sys .executable , "-m" , "dewey_service.db_seed" ], cwd = PROJECT_ROOT , check = True
151+ )
139152 console .print ("[green]Dewey TapDB overlay complete[/green]" )
140153 except (TapDBRuntimeError , subprocess .CalledProcessError ) as exc :
141154 console .print (f"[red]DB build failed:[/red] { exc } " )
@@ -146,7 +159,9 @@ def db_build(
146159def db_seed () -> None :
147160 """Apply Dewey TapDB template overlay only."""
148161 try :
149- subprocess .run ([sys .executable , "-m" , "dewey_service.db_seed" ], cwd = PROJECT_ROOT , check = True )
162+ subprocess .run (
163+ [sys .executable , "-m" , "dewey_service.db_seed" ], cwd = PROJECT_ROOT , check = True
164+ )
150165 except subprocess .CalledProcessError as exc :
151166 raise typer .Exit (exc .returncode ) from exc
152167
@@ -157,7 +172,9 @@ def db_reset(
157172 target : str = typer .Option ("local" , "--target" , help = "TapDB target: local|aurora" ),
158173 profile : str = typer .Option (DEFAULT_AWS_PROFILE , "--profile" , help = "AWS profile" ),
159174 region : str = typer .Option (DEFAULT_AWS_REGION , "--region" , help = "AWS region" ),
160- namespace : str = typer .Option (DEFAULT_TAPDB_DATABASE_NAME , "--namespace" , help = "TapDB namespace" ),
175+ namespace : str = typer .Option (
176+ DEFAULT_TAPDB_DATABASE_NAME , "--namespace" , help = "TapDB namespace"
177+ ),
161178) -> None :
162179 """Delete and rebuild TapDB target then apply Dewey overlay."""
163180 if not force and not typer .confirm ("This will delete the current TapDB DB target. Continue?" ):
@@ -188,7 +205,9 @@ def tapdb_run(
188205 target : str = typer .Option ("local" , "--target" , help = "TapDB target: local|aurora" ),
189206 profile : str = typer .Option (DEFAULT_AWS_PROFILE , "--profile" , help = "AWS profile" ),
190207 region : str = typer .Option (DEFAULT_AWS_REGION , "--region" , help = "AWS region" ),
191- namespace : str = typer .Option (DEFAULT_TAPDB_DATABASE_NAME , "--namespace" , help = "TapDB namespace" ),
208+ namespace : str = typer .Option (
209+ DEFAULT_TAPDB_DATABASE_NAME , "--namespace" , help = "TapDB namespace"
210+ ),
192211) -> None :
193212 """Run raw tapdb CLI arguments through Dewey runtime context."""
194213 if not ctx .args :
@@ -218,9 +237,13 @@ def tapdb_run(
218237@cognito_app .command ("status" )
219238def cognito_status () -> None :
220239 """Show daycog status for Dewey runtime."""
240+ daycog_path = shutil .which ("daycog" )
241+ if not daycog_path :
242+ console .print ("[red]daycog not found in PATH[/red]" )
243+ raise typer .Exit (1 )
221244 try :
222245 proc = subprocess .run (
223- ["daycog" , "status" ],
246+ [daycog_path , "status" ],
224247 capture_output = True ,
225248 text = True ,
226249 check = False ,
@@ -242,7 +265,7 @@ def test_run(
242265 pytest_args : list [str ] = typer .Argument (
243266 None ,
244267 help = "Optional pytest arguments, e.g. tests/test_app_boot.py -q" ,
245- )
268+ ),
246269) -> None :
247270 """Run Dewey tests."""
248271 args = list (pytest_args or ["-q" ])
@@ -257,12 +280,16 @@ def test_run(
257280@quality_app .command ("lint" )
258281def quality_lint () -> None :
259282 """Run Ruff lint checks."""
260- proc = subprocess .run ([sys .executable , "-m" , "ruff" , "check" , "." ], cwd = PROJECT_ROOT , check = False )
283+ proc = subprocess .run (
284+ [sys .executable , "-m" , "ruff" , "check" , "." ], cwd = PROJECT_ROOT , check = False
285+ )
261286 raise typer .Exit (proc .returncode )
262287
263288
264289@quality_app .command ("format" )
265- def quality_format (check : bool = typer .Option (True , "--check/--fix" , help = "Check or apply formatting" )) -> None :
290+ def quality_format (
291+ check : bool = typer .Option (True , "--check/--fix" , help = "Check or apply formatting" ),
292+ ) -> None :
266293 """Run Ruff formatter."""
267294 cmd = [sys .executable , "-m" , "ruff" , "format" , "." ]
268295 if check :
@@ -274,7 +301,9 @@ def quality_format(check: bool = typer.Option(True, "--check/--fix", help="Check
274301@quality_app .command ("check" )
275302def quality_check () -> None :
276303 """Run lint then tests."""
277- lint = subprocess .run ([sys .executable , "-m" , "ruff" , "check" , "." ], cwd = PROJECT_ROOT , check = False )
304+ lint = subprocess .run (
305+ [sys .executable , "-m" , "ruff" , "check" , "." ], cwd = PROJECT_ROOT , check = False
306+ )
278307 if lint .returncode != 0 :
279308 raise typer .Exit (lint .returncode )
280309 tests = subprocess .run ([sys .executable , "-m" , "pytest" , "-q" ], cwd = PROJECT_ROOT , check = False )
@@ -285,8 +314,12 @@ def quality_check() -> None:
285314def config_path () -> None :
286315 """Print resolved Dewey config paths."""
287316 settings = get_settings ()
288- console .print (f"DEWEY config path: [cyan]{ os .environ .get ('XDG_CONFIG_HOME' , '~/.config' )} /dewey/config.yaml[/cyan]" )
289- console .print (f"TAPDB config path: [cyan]{ settings .tapdb_config_path or os .environ .get ('TAPDB_CONFIG_PATH' , '' )} [/cyan]" )
317+ console .print (
318+ f"DEWEY config path: [cyan]{ os .environ .get ('XDG_CONFIG_HOME' , '~/.config' )} /dewey/config.yaml[/cyan]"
319+ )
320+ console .print (
321+ f"TAPDB config path: [cyan]{ settings .tapdb_config_path or os .environ .get ('TAPDB_CONFIG_PATH' , '' )} [/cyan]"
322+ )
290323
291324
292325@config_app .command ("show" )
0 commit comments