refactor(cli): consolidate repeated command registration (#119434)

This commit is contained in:
Peter Steinberger
2026-08-04 20:51:32 -07:00
committed by GitHub
parent f0a74970ec
commit 752dd2b5b8
4 changed files with 201 additions and 306 deletions
+16 -31
View File
@@ -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);
});
}
}