From 09a6f0da8bd430c02ea1bf70870ed66919bcaeb7 Mon Sep 17 00:00:00 2001 From: John Gee Date: Wed, 21 Oct 2026 14:02:15 +1300 Subject: [PATCH] chore: simplify scanArguments --- src/t.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/t.ts b/src/t.ts index 6ce1b22..12f2e36 100644 --- a/src/t.ts +++ b/src/t.ts @@ -163,7 +163,6 @@ export class RootCommand extends Command { parts: string[]; } { const parts: string[] = []; - const commandParts: string[] = []; let matchedCommand: Command | undefined; let canMatchCommand = true; let i = 0; @@ -185,17 +184,14 @@ export class RootCommand extends Command { parts.push(arg); if (canMatchCommand) { - commandParts.push(arg); - const commandPath = commandParts.join(' '); + const commandPath = parts.join(' '); const command = this.commands.get(commandPath); if (command) { matchedCommand = command; + } else { + canMatchCommand = false; } - - canMatchCommand = Array.from(this.commands.keys()).some( - (name) => name === commandPath || name.startsWith(`${commandPath} `) - ); } i++;