mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-24 11:25:50 -06:00
refactor(cli): consolidate repeated command registration (#119434)
This commit is contained in:
committed by
GitHub
parent
f0a74970ec
commit
752dd2b5b8
@@ -122,35 +122,20 @@ export function registerNodeCli(program: Command) {
|
||||
await runNodeDaemonInstall(opts);
|
||||
});
|
||||
|
||||
node
|
||||
.command("uninstall")
|
||||
.description("Uninstall the node host service (launchd/systemd/schtasks)")
|
||||
.option("--json", "Output JSON", false)
|
||||
.action(async (opts) => {
|
||||
await runNodeDaemonUninstall(opts);
|
||||
});
|
||||
|
||||
node
|
||||
.command("stop")
|
||||
.description("Stop the node host service (launchd/systemd/schtasks)")
|
||||
.option("--json", "Output JSON", false)
|
||||
.action(async (opts) => {
|
||||
await runNodeDaemonStop(opts);
|
||||
});
|
||||
|
||||
node
|
||||
.command("start")
|
||||
.description("Start the node host service (launchd/systemd/schtasks)")
|
||||
.option("--json", "Output JSON", false)
|
||||
.action(async (opts) => {
|
||||
await runNodeDaemonStart(opts);
|
||||
});
|
||||
|
||||
node
|
||||
.command("restart")
|
||||
.description("Restart the node host service (launchd/systemd/schtasks)")
|
||||
.option("--json", "Output JSON", false)
|
||||
.action(async (opts) => {
|
||||
await runNodeDaemonRestart(opts);
|
||||
});
|
||||
for (const [name, action] of [
|
||||
["uninstall", runNodeDaemonUninstall],
|
||||
["stop", runNodeDaemonStop],
|
||||
["start", runNodeDaemonStart],
|
||||
["restart", runNodeDaemonRestart],
|
||||
] as const) {
|
||||
node
|
||||
.command(name)
|
||||
.description(
|
||||
`${name.charAt(0).toUpperCase()}${name.slice(1)} the node host service (launchd/systemd/schtasks)`,
|
||||
)
|
||||
.option("--json", "Output JSON", false)
|
||||
.action(async (opts) => {
|
||||
await action(opts);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user