mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-11 06:31:01 -07:00
feat(cli): undeprecate the --prompt flag (#13981)
Co-authored-by: Allen Hutchison <adh@google.com>
This commit is contained in:
committed by
GitHub
parent
fb7640886b
commit
a2dab146b9
@@ -242,11 +242,7 @@ export async function parseArguments(settings: Settings): Promise<CliArgs> {
|
||||
type: 'string',
|
||||
description: 'Path to a file to record model responses for testing.',
|
||||
hidden: true,
|
||||
})
|
||||
.deprecateOption(
|
||||
'prompt',
|
||||
'Use the positional prompt instead. This flag will be removed in a future version.',
|
||||
),
|
||||
}),
|
||||
)
|
||||
// Register MCP subcommands
|
||||
.command(mcpCommand)
|
||||
|
||||
@@ -689,9 +689,6 @@ export async function main() {
|
||||
debugLogger.log('Session ID: %s', sessionId);
|
||||
}
|
||||
|
||||
const hasDeprecatedPromptArg = process.argv.some((arg) =>
|
||||
arg.startsWith('--prompt'),
|
||||
);
|
||||
initializeOutputListenersAndFlush();
|
||||
|
||||
await runNonInteractive({
|
||||
@@ -699,7 +696,6 @@ export async function main() {
|
||||
settings,
|
||||
input,
|
||||
prompt_id,
|
||||
hasDeprecatedPromptArg,
|
||||
resumedSessionData,
|
||||
});
|
||||
// Call cleanup before process.exit, which causes cleanup to not run
|
||||
|
||||
@@ -1418,58 +1418,6 @@ describe('runNonInteractive', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should display a deprecation warning if hasDeprecatedPromptArg is true', async () => {
|
||||
const events: ServerGeminiStreamEvent[] = [
|
||||
{ type: GeminiEventType.Content, value: 'Final Answer' },
|
||||
{
|
||||
type: GeminiEventType.Finished,
|
||||
value: { reason: undefined, usageMetadata: { totalTokenCount: 10 } },
|
||||
},
|
||||
];
|
||||
mockGeminiClient.sendMessageStream.mockReturnValue(
|
||||
createStreamFromEvents(events),
|
||||
);
|
||||
|
||||
await runNonInteractive({
|
||||
config: mockConfig,
|
||||
settings: mockSettings,
|
||||
input: 'Test input',
|
||||
prompt_id: 'prompt-id-deprecated',
|
||||
hasDeprecatedPromptArg: true,
|
||||
});
|
||||
|
||||
expect(processStderrSpy).toHaveBeenCalledWith(
|
||||
'The --prompt (-p) flag has been deprecated and will be removed in a future version. Please use a positional argument for your prompt. See gemini --help for more information.\n',
|
||||
);
|
||||
expect(processStdoutSpy).toHaveBeenCalledWith('Final Answer');
|
||||
});
|
||||
|
||||
it('should display a deprecation warning for JSON format', async () => {
|
||||
const events: ServerGeminiStreamEvent[] = [
|
||||
{ type: GeminiEventType.Content, value: 'Final Answer' },
|
||||
{
|
||||
type: GeminiEventType.Finished,
|
||||
value: { reason: undefined, usageMetadata: { totalTokenCount: 10 } },
|
||||
},
|
||||
];
|
||||
mockGeminiClient.sendMessageStream.mockReturnValue(
|
||||
createStreamFromEvents(events),
|
||||
);
|
||||
vi.mocked(mockConfig.getOutputFormat).mockReturnValue(OutputFormat.JSON);
|
||||
|
||||
await runNonInteractive({
|
||||
config: mockConfig,
|
||||
settings: mockSettings,
|
||||
input: 'Test input',
|
||||
prompt_id: 'prompt-id-deprecated-json',
|
||||
hasDeprecatedPromptArg: true,
|
||||
});
|
||||
|
||||
const deprecateText =
|
||||
'The --prompt (-p) flag has been deprecated and will be removed in a future version. Please use a positional argument for your prompt. See gemini --help for more information.\n';
|
||||
expect(processStderrSpy).toHaveBeenCalledWith(deprecateText);
|
||||
});
|
||||
|
||||
it('should emit appropriate events for streaming JSON output', async () => {
|
||||
vi.mocked(mockConfig.getOutputFormat).mockReturnValue(
|
||||
OutputFormat.STREAM_JSON,
|
||||
|
||||
@@ -51,7 +51,6 @@ interface RunNonInteractiveParams {
|
||||
settings: LoadedSettings;
|
||||
input: string;
|
||||
prompt_id: string;
|
||||
hasDeprecatedPromptArg?: boolean;
|
||||
resumedSessionData?: ResumedSessionData;
|
||||
}
|
||||
|
||||
@@ -60,7 +59,6 @@ export async function runNonInteractive({
|
||||
settings,
|
||||
input,
|
||||
prompt_id,
|
||||
hasDeprecatedPromptArg,
|
||||
resumedSessionData,
|
||||
}: RunNonInteractiveParams): Promise<void> {
|
||||
return promptIdContext.run(prompt_id, async () => {
|
||||
@@ -264,21 +262,6 @@ export async function runNonInteractive({
|
||||
let currentMessages: Content[] = [{ role: 'user', parts: query }];
|
||||
|
||||
let turnCount = 0;
|
||||
const deprecateText =
|
||||
'The --prompt (-p) flag has been deprecated and will be removed in a future version. Please use a positional argument for your prompt. See gemini --help for more information.\n';
|
||||
if (hasDeprecatedPromptArg) {
|
||||
if (streamFormatter) {
|
||||
streamFormatter.emitEvent({
|
||||
type: JsonStreamEventType.MESSAGE,
|
||||
timestamp: new Date().toISOString(),
|
||||
role: 'assistant',
|
||||
content: deprecateText,
|
||||
delta: true,
|
||||
});
|
||||
} else {
|
||||
process.stderr.write(deprecateText);
|
||||
}
|
||||
}
|
||||
while (true) {
|
||||
turnCount++;
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user