fix(cliproxy): show global help regardless of flag order before --help

Top-level cliproxy help was order-sensitive: 'cliproxy --verbose --help' fell
through to dispatch instead of showing help. Fire global help whenever there is
no real subcommand (no args or a leading flag) and --help/-h appears anywhere;
real subcommands still handle their own --help.
This commit is contained in:
Tam Nhu Tran committed 2026-06-22 12:18:50 -04:00
1 parent 40d7617cc1
commit 310f4f6e52
1 file changed
+8 -8
+8 -8
View File
@@ -146,14 +146,14 @@ export async function handleCliproxyCommand(args: string[]): Promise<void> {
const verbose = hasAnyFlag(remainingArgs, ['--verbose', '-v']); const verbose = hasAnyFlag(remainingArgs, ['--verbose', '-v']);
const command = remainingArgs[0]; const command = remainingArgs[0];
// Show global cliproxy help only when --help/-h is the top-level intent (no // Show global cliproxy help when there is no real subcommand (no args, or the
// subcommand, or the flag is the first arg). Subcommands that accept --help // first token is a flag) and --help/-h appears anywhere — order-insensitive, so
// (e.g. routing affinity --help) handle it themselves after dispatch. // `cliproxy --verbose --help` still works. Real subcommands (e.g.
if (!command || command === '--help' || command === '-h') { // `routing affinity --help`) handle --help themselves after dispatch.
if (hasAnyFlag(remainingArgs, ['--help', '-h'])) { const hasRealSubcommand = typeof command === 'string' && !command.startsWith('-');
await showHelp(); if (!hasRealSubcommand && hasAnyFlag(remainingArgs, ['--help', '-h'])) {
return; await showHelp();
} return;
} }
// Catalog commands // Catalog commands