mirror of
https://github.com/google-gemini/gemini-cli
synced 2026-04-21 13:37:17 +00:00
Reject positional prompt with --prompt-interactive
This commit is contained in:
parent
5bcb6b619d
commit
23a535c2e2
2 changed files with 39 additions and 0 deletions
|
|
@ -3278,6 +3278,42 @@ describe('parseArguments with positional prompt', () => {
|
|||
debugErrorSpy.mockRestore();
|
||||
});
|
||||
|
||||
it('should throw an error when both a positional prompt and the --prompt-interactive flag are used', async () => {
|
||||
process.argv = [
|
||||
'node',
|
||||
'script.js',
|
||||
'positional',
|
||||
'prompt',
|
||||
'--prompt-interactive',
|
||||
'interactive prompt',
|
||||
];
|
||||
|
||||
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(() => {});
|
||||
|
||||
await expect(parseArguments(createTestMergedSettings())).rejects.toThrow(
|
||||
'process.exit called',
|
||||
);
|
||||
|
||||
expect(debugErrorSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining(
|
||||
'Cannot use both a positional prompt and the --prompt-interactive (-i) flag together',
|
||||
),
|
||||
);
|
||||
|
||||
mockExit.mockRestore();
|
||||
mockConsoleError.mockRestore();
|
||||
debugErrorSpy.mockRestore();
|
||||
});
|
||||
|
||||
it('should correctly parse a positional prompt to query field', async () => {
|
||||
process.argv = ['node', 'script.js', 'positional', 'prompt'];
|
||||
const argv = await parseArguments(createTestMergedSettings());
|
||||
|
|
|
|||
|
|
@ -236,6 +236,9 @@ export async function parseArguments(
|
|||
if (argv['prompt'] && hasPositionalQuery) {
|
||||
return 'Cannot use both a positional prompt and the --prompt (-p) flag together';
|
||||
}
|
||||
if (argv['promptInteractive'] !== undefined && hasPositionalQuery) {
|
||||
return 'Cannot use both a positional prompt and the --prompt-interactive (-i) flag together';
|
||||
}
|
||||
if (argv['prompt'] && argv['promptInteractive']) {
|
||||
return 'Cannot use both --prompt (-p) and --prompt-interactive (-i) together';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue