Fix(noninteractive) - Add message when user uses deprecated flag (#11682)

Co-authored-by: gemini-cli-robot <gemini-cli-robot@google.com>
This commit is contained in:
shishu314
2025-10-29 17:54:40 -04:00
committed by GitHub
parent 82c10421a0
commit 99f75f3218
5 changed files with 275 additions and 227 deletions
+30 -6
View File
@@ -42,12 +42,21 @@ import {
} from './utils/errors.js';
import { TextOutput } from './ui/utils/textOutput.js';
export async function runNonInteractive(
config: Config,
settings: LoadedSettings,
input: string,
prompt_id: string,
): Promise<void> {
interface RunNonInteractiveParams {
config: Config;
settings: LoadedSettings;
input: string;
prompt_id: string;
hasDeprecatedPromptArg?: boolean;
}
export async function runNonInteractive({
config,
settings,
input,
prompt_id,
hasDeprecatedPromptArg,
}: RunNonInteractiveParams): Promise<void> {
return promptIdContext.run(prompt_id, async () => {
const consolePatcher = new ConsolePatcher({
stderr: true,
@@ -151,6 +160,21 @@ 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 (