mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -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',
|
type: 'string',
|
||||||
description: 'Path to a file to record model responses for testing.',
|
description: 'Path to a file to record model responses for testing.',
|
||||||
hidden: true,
|
hidden: true,
|
||||||
})
|
}),
|
||||||
.deprecateOption(
|
|
||||||
'prompt',
|
|
||||||
'Use the positional prompt instead. This flag will be removed in a future version.',
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
// Register MCP subcommands
|
// Register MCP subcommands
|
||||||
.command(mcpCommand)
|
.command(mcpCommand)
|
||||||
|
|||||||
@@ -689,9 +689,6 @@ export async function main() {
|
|||||||
debugLogger.log('Session ID: %s', sessionId);
|
debugLogger.log('Session ID: %s', sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasDeprecatedPromptArg = process.argv.some((arg) =>
|
|
||||||
arg.startsWith('--prompt'),
|
|
||||||
);
|
|
||||||
initializeOutputListenersAndFlush();
|
initializeOutputListenersAndFlush();
|
||||||
|
|
||||||
await runNonInteractive({
|
await runNonInteractive({
|
||||||
@@ -699,7 +696,6 @@ export async function main() {
|
|||||||
settings,
|
settings,
|
||||||
input,
|
input,
|
||||||
prompt_id,
|
prompt_id,
|
||||||
hasDeprecatedPromptArg,
|
|
||||||
resumedSessionData,
|
resumedSessionData,
|
||||||
});
|
});
|
||||||
// Call cleanup before process.exit, which causes cleanup to not run
|
// 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 () => {
|
it('should emit appropriate events for streaming JSON output', async () => {
|
||||||
vi.mocked(mockConfig.getOutputFormat).mockReturnValue(
|
vi.mocked(mockConfig.getOutputFormat).mockReturnValue(
|
||||||
OutputFormat.STREAM_JSON,
|
OutputFormat.STREAM_JSON,
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ interface RunNonInteractiveParams {
|
|||||||
settings: LoadedSettings;
|
settings: LoadedSettings;
|
||||||
input: string;
|
input: string;
|
||||||
prompt_id: string;
|
prompt_id: string;
|
||||||
hasDeprecatedPromptArg?: boolean;
|
|
||||||
resumedSessionData?: ResumedSessionData;
|
resumedSessionData?: ResumedSessionData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +59,6 @@ export async function runNonInteractive({
|
|||||||
settings,
|
settings,
|
||||||
input,
|
input,
|
||||||
prompt_id,
|
prompt_id,
|
||||||
hasDeprecatedPromptArg,
|
|
||||||
resumedSessionData,
|
resumedSessionData,
|
||||||
}: RunNonInteractiveParams): Promise<void> {
|
}: RunNonInteractiveParams): Promise<void> {
|
||||||
return promptIdContext.run(prompt_id, async () => {
|
return promptIdContext.run(prompt_id, async () => {
|
||||||
@@ -264,21 +262,6 @@ export async function runNonInteractive({
|
|||||||
let currentMessages: Content[] = [{ role: 'user', parts: query }];
|
let currentMessages: Content[] = [{ role: 'user', parts: query }];
|
||||||
|
|
||||||
let turnCount = 0;
|
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) {
|
while (true) {
|
||||||
turnCount++;
|
turnCount++;
|
||||||
if (
|
if (
|
||||||
|
|||||||
Reference in New Issue
Block a user