refactor(auto-reply): share standard set/unset slash parsing

This commit is contained in:
Peter Steinberger
2026-02-18 23:08:18 +00:00
parent 6cbd00a3c6
commit 6eb0964fa6
4 changed files with 53 additions and 10 deletions

View File

@@ -1,4 +1,4 @@
import { parseSlashCommandWithSetUnset } from "./commands-setunset.js";
import { parseStandardSetUnsetSlashCommand } from "./commands-setunset-standard.js";
export type ConfigCommand =
| { action: "show"; path?: string }
@@ -7,7 +7,7 @@ export type ConfigCommand =
| { action: "error"; message: string };
export function parseConfigCommand(raw: string): ConfigCommand | null {
return parseSlashCommandWithSetUnset<ConfigCommand>({
return parseStandardSetUnsetSlashCommand<ConfigCommand>({
raw,
slash: "/config",
invalidMessage: "Invalid /config syntax.",
@@ -18,8 +18,5 @@ export function parseConfigCommand(raw: string): ConfigCommand | null {
}
return undefined;
},
onSet: (path, value) => ({ action: "set", path, value }),
onUnset: (path) => ({ action: "unset", path }),
onError: (message) => ({ action: "error", message }),
});
}