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

Positional prompt argument is ignored when other flags are present

Open sniemczyk-google opened this issue 1 year ago • 6 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.

Steps to reproduce:

  1. Run gemini -e none Hello

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).

Workaround:

Using the -p or --prompt flag explicitly works as expected: gemini -e none -p Hello

Client information

Client Information

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

> /about

╭───────────────────────────────────────────────────────╮
│                                                       │
│ About Gemini CLI                                      │
│                                                       │
│ CLI Version        0.6.0-nightly-git.c4c81e3d         │
│ Git Commit         c4c81e3d                           │
│ Model              gemini-2.5-pro                     │
│ Sandbox            no sandbox                         │
│ OS                 linux                              │
│ Auth Method        gemini-api-key                     │
│                                                       │
╰───────────────────────────────────────────────────────╯

Login information

Gemini API Key

Anything else we need to know?

No response

sniemczyk-google avatar Sep 18 '25 13:09 sniemczyk-google

This issue is a bug where the CLI's core command parsing fails to handle positional prompt arguments when other flags are present. It's a medium priority issue as a simple workaround exists.

gemini-cli[bot] avatar Sep 18 '25 14:09 gemini-cli[bot]

Please re-open this issue. gemini -e none hello still does not work

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

I "re-opened" with issue #10004 cc: @allenhutchison

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

@sniemczyk-google I think this is fixed now, can you verify?

allenhutchison avatar Oct 11 '25 17:10 allenhutchison

This is still broken

While the literally simplest prompt now works, gemini -e none Hello try anything more complex:

gemini -e none --approval-mode=auto_edit --allowed-tools=ShellTool --allowed-tools="ShellTool(whoami)" --allowed-tools="ShellTool(wc)" -p "Use whoami to write a poem in file poem.md about my username in pig latin and use wc to tell me how many lines are in the poem you wrote."

While the above produces an answer (e.g. 3) If you remove the -p and it now jumps into Gemini with the splash screen:

gemini -e none --approval-mode=auto_edit --allowed-tools=ShellTool --allowed-tools="ShellTool(whoami)" --allowed-tools="ShellTool(wc)" "Use whoami to write a poem in file poem.md about my username in pig latin and use wc to tell me how many lines are in the poem you wrote."

This is especially problematic since the prompt CLI option is considered deprecated in favor of the position one while the positional one does not seem to work reliably at all.

sniemczyk-google avatar Oct 13 '25 21:10 sniemczyk-google

I spent some time digging into this last night. i see where the oversight is and am testing a fix.

allenhutchison avatar Oct 14 '25 16:10 allenhutchison