From e7d9451557bc89af92c2ce334ea08204e086cdd4 Mon Sep 17 00:00:00 2001 From: redshift <213178690+1ftredsh@users.noreply.github.com> Date: Fri, 14 Aug 2026 19:13:26 +0100 Subject: [PATCH] feat: add 'routstrd local' command to switch back to local daemon mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 'routstrd remote ' command sets daemonUrl/authUrl in the config to point at a remote daemon. There was no CLI command to switch back to local mode — users had to manually edit config.json to remove those fields. This adds 'routstrd local' which: - Removes daemonUrl and authUrl from the config file - Preserves all other config (nsec, port, host, etc.) - Shows a clear message about what was removed - Handles the already-local case gracefully --- src/cli.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/cli.ts b/src/cli.ts index 3d4084e..1a39908 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -586,6 +586,39 @@ program } }); +// Local - switch back to local daemon mode (removes daemonUrl/authUrl) +program + .command("local") + .description("Switch back to local daemon mode (removes remote daemon URL)") + .action(async () => { + const config = await loadConfig(); + + if (!config.daemonUrl && !config.authUrl) { + console.log("Already in local mode — no remote daemon URL is configured."); + return; + } + + const previousDaemonUrl = config.daemonUrl; + const previousAuthUrl = config.authUrl; + + const { daemonUrl: _daemonUrl, authUrl: _authUrl, ...rest } = config; + const updatedConfig: RoutstrdConfig = rest; + + await Bun.write(CONFIG_FILE, JSON.stringify(updatedConfig, null, 2)); + + console.log("Switched back to local daemon mode."); + if (previousDaemonUrl) { + console.log(` Removed remote daemon URL: ${previousDaemonUrl}`); + } + if (previousAuthUrl) { + console.log(` Removed auth proxy URL: ${previousAuthUrl}`); + } + console.log( + `\nUse 'routstrd start' to start the local daemon.`, + ); + console.log(`You can view the config file at: ${CONFIG_FILE}`); + }); + // Onboard - initialize the daemon program .command("onboard")