12 lines
565 B
TypeScript
12 lines
565 B
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { parseCommand } from "../src/parser";
|
|
|
|
test("command parser handles quotes, escapes, inline flags and terminator", () => {
|
|
const parsed = parseCommand('new "The Clockwork Sea" --mode=strict-autopilot -- --literal \\ value');
|
|
assert.equal(parsed.verb, "new");
|
|
assert.deepEqual(parsed.args, ["The Clockwork Sea", "--literal", " value"]);
|
|
assert.equal(parsed.flags.get("mode"), "strict-autopilot");
|
|
assert.throws(() => parseCommand('new "unfinished'), /Unterminated quote/);
|
|
});
|