feat: add 'routstrd local' command to switch back to local daemon mode

The 'routstrd remote <url>' 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
This commit is contained in:
redshift
2026-08-14 19:13:26 +01:00
parent b187cd3803
commit e7d9451557
+33
View File
@@ -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")