import os import click from app import create_app from app.config import load_config @click.group() def main(): """PKM CLI.""" pass @main.command("run") @click.option("--vault", "vault_path", type=click.Path(file_okay=False, dir_okay=True, path_type=str), help="Path to the vault directory") @click.option("--host", default="127.0.0.1", show_default=True, help="Host to bind") @click.option("--port", default=5000, show_default=True, help="Port to bind") @click.option("--debug/--no-debug", default=True, show_default=True, help="Enable/disable debug mode") def runserver(vault_path: str | None, host: str, port: int, debug: bool): """Run the development server.""" # Prefer CLI vault over env cfg = load_config(vault_override=vault_path) # Mirror into environment for consistency if needed if cfg.VAULT_PATH: os.environ["KB_VAULT_PATH"] = cfg.VAULT_PATH os.environ["FLASK_DEBUG"] = "1" if debug else "0" app = create_app(cfg) app.run(host=host, port=port, debug=debug) if __name__ == "__main__": main()