diff --git a/trobz_local/main.py b/trobz_local/main.py index da572ca..4a3ad76 100644 --- a/trobz_local/main.py +++ b/trobz_local/main.py @@ -1,3 +1,4 @@ +import os import subprocess import urllib.request from enum import Enum @@ -621,6 +622,24 @@ def ensure_db_user(ctx: typer.Context): } +@app.command() +def edit_config(): + """Open config.toml in your editor.""" + code_root = get_code_root() + config_path = code_root / "config.toml" + + if not config_path.exists(): + typer.secho(f"Config file not found: {config_path}", fg=typer.colors.YELLOW) + typer.echo("Generate one first with: tlc generate-config ") + raise typer.Exit(code=1) + + editor = os.environ.get("EDITOR", "vi") + result = subprocess.run([editor, str(config_path)]) # noqa: S603 + if result.returncode != 0: + typer.secho(f"Editor exited with code {result.returncode}", fg=typer.colors.RED) + raise typer.Exit(code=1) + + @app.command() def doctor(): """Check the health of your local development environment."""