feat(tui): add /elev alias
This commit is contained in:
16
src/tui/commands.test.ts
Normal file
16
src/tui/commands.test.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { parseCommand } from "./commands.js";
|
||||
|
||||
describe("tui slash commands", () => {
|
||||
it("treats /elev as an alias for /elevated", () => {
|
||||
expect(parseCommand("/elev on")).toEqual({ name: "elevated", args: "on" });
|
||||
});
|
||||
|
||||
it("normalizes alias case", () => {
|
||||
expect(parseCommand("/ELEV off")).toEqual({
|
||||
name: "elevated",
|
||||
args: "off",
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -11,11 +11,19 @@ export type ParsedCommand = {
|
||||
args: string;
|
||||
};
|
||||
|
||||
const COMMAND_ALIASES: Record<string, string> = {
|
||||
elev: "elevated",
|
||||
};
|
||||
|
||||
export function parseCommand(input: string): ParsedCommand {
|
||||
const trimmed = input.replace(/^\//, "").trim();
|
||||
if (!trimmed) return { name: "", args: "" };
|
||||
const [name, ...rest] = trimmed.split(/\s+/);
|
||||
return { name: name.toLowerCase(), args: rest.join(" ").trim() };
|
||||
const normalized = name.toLowerCase();
|
||||
return {
|
||||
name: COMMAND_ALIASES[normalized] ?? normalized,
|
||||
args: rest.join(" ").trim(),
|
||||
};
|
||||
}
|
||||
|
||||
export function getSlashCommands(): SlashCommand[] {
|
||||
@@ -53,6 +61,14 @@ export function getSlashCommands(): SlashCommand[] {
|
||||
(value) => ({ value, label: value }),
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "elev",
|
||||
description: "Alias for /elevated",
|
||||
getArgumentCompletions: (prefix) =>
|
||||
ELEVATED_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map(
|
||||
(value) => ({ value, label: value }),
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "activation",
|
||||
description: "Set group activation",
|
||||
@@ -88,6 +104,7 @@ export function helpText(): string {
|
||||
"/think <off|minimal|low|medium|high>",
|
||||
"/verbose <on|off>",
|
||||
"/elevated <on|off>",
|
||||
"/elev <on|off>",
|
||||
"/activation <mention|always>",
|
||||
"/deliver <on|off>",
|
||||
"/new or /reset",
|
||||
|
||||
Reference in New Issue
Block a user