mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-29 14:34:55 -07:00
fix(resume): allow passing a prompt via stdin while resuming using --resume (#13520)
This commit is contained in:
@@ -435,37 +435,15 @@ describe('parseArguments', () => {
|
|||||||
debugErrorSpy.mockRestore();
|
debugErrorSpy.mockRestore();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error when resuming a session without prompt in non-interactive mode', async () => {
|
it('should allow resuming a session without prompt argument in non-interactive mode (expecting stdin)', async () => {
|
||||||
const originalIsTTY = process.stdin.isTTY;
|
const originalIsTTY = process.stdin.isTTY;
|
||||||
process.stdin.isTTY = false;
|
process.stdin.isTTY = false;
|
||||||
process.argv = ['node', 'script.js', '--resume', 'session-id'];
|
process.argv = ['node', 'script.js', '--resume', 'session-id'];
|
||||||
|
|
||||||
const mockExit = vi.spyOn(process, 'exit').mockImplementation(() => {
|
|
||||||
throw new Error('process.exit called');
|
|
||||||
});
|
|
||||||
|
|
||||||
const mockConsoleError = vi
|
|
||||||
.spyOn(console, 'error')
|
|
||||||
.mockImplementation(() => {});
|
|
||||||
const debugErrorSpy = vi
|
|
||||||
.spyOn(debugLogger, 'error')
|
|
||||||
.mockImplementation(() => {});
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await expect(parseArguments({} as Settings)).rejects.toThrow(
|
const argv = await parseArguments({} as Settings);
|
||||||
'process.exit called',
|
expect(argv.resume).toBe('session-id');
|
||||||
);
|
|
||||||
|
|
||||||
expect(debugErrorSpy).toHaveBeenCalledWith(
|
|
||||||
expect.stringContaining(
|
|
||||||
'When resuming a session, you must provide a message via --prompt (-p) or stdin',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
expect(mockConsoleError).toHaveBeenCalled();
|
|
||||||
} finally {
|
} finally {
|
||||||
mockExit.mockRestore();
|
|
||||||
mockConsoleError.mockRestore();
|
|
||||||
debugErrorSpy.mockRestore();
|
|
||||||
process.stdin.isTTY = originalIsTTY;
|
process.stdin.isTTY = originalIsTTY;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -262,11 +262,6 @@ export async function parseArguments(settings: Settings): Promise<CliArgs> {
|
|||||||
if (argv['prompt'] && argv['promptInteractive']) {
|
if (argv['prompt'] && argv['promptInteractive']) {
|
||||||
return 'Cannot use both --prompt (-p) and --prompt-interactive (-i) together';
|
return 'Cannot use both --prompt (-p) and --prompt-interactive (-i) together';
|
||||||
}
|
}
|
||||||
if (argv['resume'] && !argv['prompt'] && !process.stdin.isTTY) {
|
|
||||||
throw new Error(
|
|
||||||
'When resuming a session, you must provide a message via --prompt (-p) or stdin',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (argv['yolo'] && argv['approvalMode']) {
|
if (argv['yolo'] && argv['approvalMode']) {
|
||||||
return 'Cannot use both --yolo (-y) and --approval-mode together. Use --approval-mode=yolo instead.';
|
return 'Cannot use both --yolo (-y) and --approval-mode together. Use --approval-mode=yolo instead.';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user