Files
openclaw/src/cli/program/register.setup.ts

54 lines
2.1 KiB
TypeScript
Raw Normal View History

2026-01-14 01:08:15 +00:00
import type { Command } from "commander";
import { onboardCommand } from "../../commands/onboard.js";
import { setupCommand } from "../../commands/setup.js";
import { defaultRuntime } from "../../runtime.js";
2026-01-15 06:12:54 +00:00
import { formatDocsLink } from "../../terminal/links.js";
import { theme } from "../../terminal/theme.js";
import { runCommandWithRuntime } from "../cli-utils.js";
import { hasExplicitOptions } from "../command-options.js";
2026-01-14 01:08:15 +00:00
export function registerSetupCommand(program: Command) {
program
.command("setup")
2026-01-30 03:15:10 +01:00
.description("Initialize ~/.openclaw/openclaw.json and the agent workspace")
2026-01-15 06:12:54 +00:00
.addHelpText(
"after",
2026-01-15 07:46:51 +00:00
() =>
2026-01-30 03:15:10 +01:00
`\n${theme.muted("Docs:")} ${formatDocsLink("/cli/setup", "docs.openclaw.ai/cli/setup")}\n`,
2026-01-15 06:12:54 +00:00
)
2026-01-14 01:08:15 +00:00
.option(
"--workspace <dir>",
2026-01-30 03:15:10 +01:00
"Agent workspace directory (default: ~/.openclaw/workspace; stored as agents.defaults.workspace)",
2026-01-14 01:08:15 +00:00
)
.option("--wizard", "Run the interactive onboarding wizard", false)
.option("--non-interactive", "Run the wizard without prompts", false)
.option("--mode <mode>", "Wizard mode: local|remote")
.option("--remote-url <url>", "Remote Gateway WebSocket URL")
.option("--remote-token <token>", "Remote Gateway token (optional)")
.action(async (opts, command) => {
await runCommandWithRuntime(defaultRuntime, async () => {
2026-01-14 01:08:15 +00:00
const hasWizardFlags = hasExplicitOptions(command, [
"wizard",
"nonInteractive",
"mode",
"remoteUrl",
"remoteToken",
]);
if (opts.wizard || hasWizardFlags) {
await onboardCommand(
{
workspace: opts.workspace as string | undefined,
nonInteractive: Boolean(opts.nonInteractive),
mode: opts.mode as "local" | "remote" | undefined,
remoteUrl: opts.remoteUrl as string | undefined,
remoteToken: opts.remoteToken as string | undefined,
},
defaultRuntime,
);
return;
}
await setupCommand({ workspace: opts.workspace as string | undefined }, defaultRuntime);
});
2026-01-14 01:08:15 +00:00
});
}