Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

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

Garry Tanf7295e33082a
diff --git a/src/cli.ts b/src/cli.ts
index 854c1de885..ba62f41473 100755
--- a/src/cli.ts
+++ b/src/cli.ts
@@ -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.
diff --git a/test/cli.test.ts b/test/cli.test.ts
index 121e6dd61a..feafbd71da 100644
--- a/test/cli.test.ts
+++ b/test/cli.test.ts
@@ -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 {