gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

Regression: Positional prompt argument is still ignored with other flags

Open sniemczyk-google opened this issue 1 year ago • 2 comments

What happened?

When providing a prompt as a positional argument along with other flags (e.g., gemini -e none "Hello, world!"), the Gemini CLI ignores the positional prompt and enters interactive mode. It displays the Gemini logo and does not process the prompt.

This is a regression of issue #8689.

What did you expect to happen?

The CLI should process "Hello" as the prompt and return a response, even when other flags are present. The expected behavior is that the CLI processes the positional prompt regardless of other flags being present, consistent with how it works when no other flags are provided (gemini Hello).

Client information

Client Information

Run gemini to enter the interactive CLI, then run the /about command.

> /about

╭───────────────────────────────────────────────────────────────────────────────────╮
│                                                                                   │
│ About Gemini CLI                                                                  │
│                                                                                   │
│ CLI Version                 0.8.0-nightly.20250925.b1da8c21-git.11c995e9          │
│ Git Commit                  11c995e9                                              │
│ Model                       auto                                                  │
│ Sandbox                     no sandbox                                            │
│ OS                          linux                                                 │
│ Auth Method                 gemini-api-key                                        │
│                                                                                   │
╰───────────────────────────────────────────────────────────────────────────────────╯

Login information

Gemini API Key

Anything else we need to know?

This issue was previously reported in #8689 and was supposedly fixed in PR #9004. However, the issue still persists in the latest nightly build. As per my conversation with @allenhutchison, I'm filing this new issue since I don't have permissions to reopen the original one.

sniemczyk-google avatar Sep 26 '25 23:09 sniemczyk-google

Re-opened per the comment Thanks for your feedback @sniemczyk-google

srithreepo avatar Sep 26 '25 23:09 srithreepo

Issue Resolved ✅

The problem was that PR #9004's fix wasn't fully applied due to missing yargs configuration. After further investigation, I found that two critical settings were missing:

Root Cause

  1. positional('promptWords', ...) configuration was removed
  2. nargs: 1 setting for the extensions option was removed

Solution Applied

  • ✅ Restored positional('promptWords', ...) configuration
  • ✅ Restored nargs: 1 setting for extensions option
  • ✅ Added comprehensive test case for gemini -e none hello scenario

Verification

# Now works correctly (non-interactive mode)
gemini -e none hello

# Also works (non-interactive mode)
gemini --model gemini-1.5-pro hello

# Still works (interactive mode)
gemini --model gemini-1.5-pro

Test Coverage Added

it('should not be interactive if positional prompt words are provided with extensions flag', async () => {
  process.stdin.isTTY = true;
  process.argv = ['node', 'script.js', '-e', 'none', 'hello'];
  const argv = await parseArguments({} as Settings);
  const config = await loadCliConfig({}, [], 'test-session', argv);
  expect(config.isInteractive()).toBe(false);
  expect(argv.promptWords).toEqual(['hello']);
  expect(argv.extensions).toEqual(['none']);
});

All interactive mode tests are passing.

Related PR

Created PR to fix this issue: #10077

The positional prompt argument issue is now completely resolved! 🎉

seeun0210 avatar Sep 27 '25 15:09 seeun0210