fix(cli): route init --help to its own usage text (#3652)

Co-Authored-By: Time Attakc <89218912+time-attack@users.noreply.github.com>
This commit is contained in:
Garry Tan
2026-08-01 07:40:48 +08:00
committed by Sina Matian
co-authored by Time Attakc
parent f84bfb57f2
commit f7295e3308
2 changed files with 11 additions and 1 deletions
+5
View File
@@ -107,6 +107,11 @@ const CLI_ONLY_SELF_HELP = new Set([
// `gbrain connect --help` prints its own usage (flags + examples) from
// runConnect; route around the generic one-line short-circuit.
'connect',
// `gbrain init --help` prints its own usage from runInit; route around the
// generic one-line short-circuit (matches `connect`). Without this, `init`
// is in CLI_ONLY but not CLI_ONLY_SELF_HELP, so the dispatcher's generic
// short-circuit fires and the printInitHelp() guard in init.ts is dead code.
'init',
// #3390 — `gbrain migrate embeddings --help` / `gbrain retrieval-upgrade
// --help` print the migration flags from runMigrateEmbeddings. `migrate`
// (engine transfer) keeps its own dispatch too.
+6 -1
View File
@@ -195,7 +195,12 @@ describe('CLI dispatch integration', () => {
});
const stdout = await new Response(proc.stdout).text();
const exitCode = await proc.exited;
expect(stdout).toContain('Usage: gbrain init');
// init prints its OWN detailed help (printInitHelp), not the generic
// CLI-only one-line stub. Assert on markers unique to the real help...
expect(stdout).toContain('gbrain init [flags]');
expect(stdout).toContain('ENGINE SELECTION');
// ...and confirm the generic stub (printCliOnlyHelp) did NOT fire.
expect(stdout).not.toContain('run gbrain --help for the full command list');
expect(existsSync(join(home, '.gbrain', 'config.json'))).toBe(false);
expect(exitCode).toBe(0);
} finally {