Skip to content

Commit cecdfd1

Browse files
fix(cli): move help/version exit logic to main and fix E2E failures
1 parent 81aabda commit cecdfd1

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

packages/cli/src/config/config.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ import {
5858

5959
import { loadSandboxConfig } from './sandboxConfig.js';
6060
import { resolvePath } from '../utils/resolvePath.js';
61-
import { runExitCleanup } from '../utils/cleanup.js';
6261
import { isRecord } from '../utils/settingsUtils.js';
6362
import { RESUME_LATEST } from '../utils/sessionUtils.js';
6463

@@ -83,6 +82,9 @@ export interface CliArgs {
8382
promptInteractive: string | undefined;
8483
worktree?: string;
8584

85+
help?: boolean;
86+
version?: boolean;
87+
8688
yolo: boolean | undefined;
8789
approvalMode: string | undefined;
8890
policy: string[] | undefined;
@@ -522,17 +524,6 @@ export async function parseArguments(
522524
throw new FatalConfigError(msg);
523525
}
524526

525-
// Handle help and version flags manually since we disabled exitProcess
526-
if (result['help'] || result['version']) {
527-
if (
528-
process.env['VITEST'] !== 'true' &&
529-
process.env['GEMINI_CLI_INTEGRATION_TEST'] !== 'true'
530-
) {
531-
await runExitCleanup();
532-
process.exit(0);
533-
}
534-
}
535-
536527
// Normalize query args: handle both quoted "@path file" and unquoted @path file
537528
const queryArg = result['query'];
538529
let q: string | undefined;

packages/cli/src/gemini.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,17 @@ export async function main() {
423423

424424
const argv = await argvPromise;
425425

426+
if (argv.help || argv.version) {
427+
if (
428+
process.env['VITEST'] === 'true' ||
429+
process.env['GEMINI_CLI_INTEGRATION_TEST'] === 'true'
430+
) {
431+
return;
432+
}
433+
await runExitCleanup();
434+
process.exit(0);
435+
}
436+
426437
const { sessionId, resumedSessionData } = await resolveSessionId(
427438
argv.resume,
428439
argv.sessionId,

0 commit comments

Comments
 (0)