From eb387df905bb41abd13151f38a1d6c10afaff623 Mon Sep 17 00:00:00 2001 From: trisdoan Date: Fri, 20 Mar 2026 10:01:20 +0700 Subject: [PATCH] feat: add edit command to open config.toml in editor --- trobz_local/main.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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."""