chore: Enable "curly" rule to avoid single-statement if confusion/errors.

This commit is contained in:
cpojer
2026-01-31 16:19:20 +09:00
parent 009b16fab8
commit 5ceff756e1
1266 changed files with 27871 additions and 9393 deletions

View File

@@ -11,8 +11,12 @@ type SystemEventOpts = GatewayRpcOpts & { text?: string; mode?: string; json?: b
const normalizeWakeMode = (raw: unknown) => {
const mode = typeof raw === "string" ? raw.trim() : "";
if (!mode) return "next-heartbeat" as const;
if (mode === "now" || mode === "next-heartbeat") return mode;
if (!mode) {
return "next-heartbeat" as const;
}
if (mode === "now" || mode === "next-heartbeat") {
return mode;
}
throw new Error("--mode must be now or next-heartbeat");
};
@@ -36,11 +40,16 @@ export function registerSystemCli(program: Command) {
).action(async (opts: SystemEventOpts) => {
try {
const text = typeof opts.text === "string" ? opts.text.trim() : "";
if (!text) throw new Error("--text is required");
if (!text) {
throw new Error("--text is required");
}
const mode = normalizeWakeMode(opts.mode);
const result = await callGatewayFromCli("wake", opts, { mode, text }, { expectFinal: false });
if (opts.json) defaultRuntime.log(JSON.stringify(result, null, 2));
else defaultRuntime.log("ok");
if (opts.json) {
defaultRuntime.log(JSON.stringify(result, null, 2));
} else {
defaultRuntime.log("ok");
}
} catch (err) {
defaultRuntime.error(danger(String(err)));
defaultRuntime.exit(1);