Skip to content

Commit 465967b

Browse files
RyanLee-Devclaude
andcommitted
feat: auto-forward single-subcommand groups
When a group has exactly one leaf command, typing the group name alone executes it directly instead of erroring. minimax quota → minimax quota show minimax music → minimax music generate minimax search → minimax search query Groups with multiple subcommands (auth, video, text, etc.) are unaffected and still show the group help. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d42127a commit 465967b

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/registry.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ class CommandRegistry {
7777
return { command: node.command, extra: commandPath.slice(matched.length) };
7878
}
7979

80+
// Single child: auto-forward (e.g. `minimax quota` → `minimax quota show`)
81+
if (matched.length > 0 && node.children.size === 1) {
82+
const [, child] = node.children.entries().next().value as [string, CommandNode];
83+
if (child.command) {
84+
return { command: child.command, extra: commandPath.slice(matched.length) };
85+
}
86+
}
87+
8088
// If we matched some path but no command, show help for that group
8189
if (matched.length > 0 && node.children.size > 0) {
8290
const subcommands = Array.from(node.children.entries())

0 commit comments

Comments
 (0)