mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-15 03:50:40 +00:00
30 lines
931 B
TypeScript
30 lines
931 B
TypeScript
import { parseSlashCommandWithSetUnset } from "./commands-setunset.js";
|
|
|
|
export type DebugCommand =
|
|
| { action: "show" }
|
|
| { action: "reset" }
|
|
| { action: "set"; path: string; value: unknown }
|
|
| { action: "unset"; path: string }
|
|
| { action: "error"; message: string };
|
|
|
|
export function parseDebugCommand(raw: string): DebugCommand | null {
|
|
return parseSlashCommandWithSetUnset<DebugCommand>({
|
|
raw,
|
|
slash: "/debug",
|
|
invalidMessage: "Invalid /debug syntax.",
|
|
usageMessage: "Usage: /debug show|set|unset|reset",
|
|
onKnownAction: (action) => {
|
|
if (action === "show") {
|
|
return { action: "show" };
|
|
}
|
|
if (action === "reset") {
|
|
return { action: "reset" };
|
|
}
|
|
return undefined;
|
|
},
|
|
onSet: (path, value) => ({ action: "set", path, value }),
|
|
onUnset: (path) => ({ action: "unset", path }),
|
|
onError: (message) => ({ action: "error", message }),
|
|
});
|
|
}
|