chore: tests for rule

This commit is contained in:
2026-04-01 22:31:07 +08:00
parent 170217db30
commit ad0d349090
3 changed files with 438 additions and 10 deletions
+5 -4
View File
@@ -230,9 +230,9 @@ function tokenize(input: string): string[] {
* parseCommandSchema('move <from: [x: string; y: string]> <to: string> [--all]')
* parseCommandSchema('move <from> <to> [--speed: number = 10 -s]')
*/
export function parseCommandSchema(schemaStr: string): CommandSchema {
export function parseCommandSchema(schemaStr: string, name?: string): CommandSchema {
const schema: CommandSchema = {
name: '',
name: name ?? '',
params: [],
options: [],
flags: [],
@@ -243,9 +243,10 @@ export function parseCommandSchema(schemaStr: string): CommandSchema {
return schema;
}
schema.name = tokens[0];
const startIdx = name !== undefined ? 0 : 1;
schema.name = name ?? tokens[0];
let i = 1;
let i = startIdx;
while (i < tokens.length) {
const token = tokens[i];