refactor: merge /spark command into /roll
Consolidate the `/spark` command into `/roll` to simplify the CLI. The `/roll` command now handles both dice notation and spark table slugs. - Update `parseInput` to treat `/roll` arguments as a generic string. - Update `dispatchCommand` to check for spark table matches before evaluating dice notation or variable expressions. - Update command completions to show both dice and spark table suggestions under `/roll`. - Update documentation and UI placeholders to reflect the change.
This commit is contained in:
@@ -690,16 +690,16 @@ describe("var-reactivity", () => {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
describe("parseInput", () => {
|
||||
test("parses /roll command", () => {
|
||||
const result = parseInput("/roll 3d6+5");
|
||||
test("parses /roll command with spark table slug", () => {
|
||||
const result = parseInput("/roll my-table");
|
||||
expect(result.type).toBe("roll");
|
||||
expect(result.payload).toEqual({ notation: "3d6+5", label: "3d6+5" });
|
||||
expect(result.payload).toEqual({ arg: "my-table" });
|
||||
});
|
||||
|
||||
test("parses /spark command", () => {
|
||||
const result = parseInput("/spark my-table");
|
||||
expect(result.type).toBe("spark");
|
||||
expect(result.payload).toEqual({ key: "my-table" });
|
||||
test("parses /roll command with dice notation", () => {
|
||||
const result = parseInput("/roll 3d6+5");
|
||||
expect(result.type).toBe("roll");
|
||||
expect(result.payload).toEqual({ arg: "3d6+5" });
|
||||
});
|
||||
|
||||
test("parses /link command", () => {
|
||||
@@ -743,7 +743,7 @@ describe("parseInput", () => {
|
||||
|
||||
test("returns error for empty /roll", () => {
|
||||
const result = parseInput("/roll ");
|
||||
expect(result.error).toBe("需要骰子表达式");
|
||||
expect(result.error).toBe("需要骰子表达式或种子表键名");
|
||||
});
|
||||
|
||||
test("returns error for empty /set", () => {
|
||||
|
||||
Reference in New Issue
Block a user