mirror of
https://github.com/Routstr/routstrd.git
synced 2026-10-06 04:38:23 +00:00
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:
+33
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user