--interactive does not fall back to line prompts when stdin/stdout are not TTYs

Aperta
#246 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
67/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go
Ambito
cli, testing

Direzione di ricerca

Read internal/interactive/policy.go and the help text in internal/cli/root.go, then inspect tests/contract/porcelain_interactive_test.go. Start by tracing how --interactive, TTY detection, and the prompter determine whether prompts activate; add the subprocess pipe contract coverage requested in the issue. Done means piped input prompts when --interactive is enabled while default and --no-interactive behavior remain non-interactive.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Description of the bug:

Summary

The root help says --interactive will prompt for missing inputs and that forms fall back to line prompts on stdin when running off-TTY. However, with piped/non-TTY stdin and stdout, the CLI exits on missing required arguments without prompting or consuming the input.

Reproduction

Build the current main branch, then run:

go build -o /tmp/gemini-api ./cmd/gemini-api
printf '/tmp/no-such-file.png\nwhat is this?\n' | \
  /tmp/gemini-api --interactive --dry-run --api-key k \
  --server-url https://example.invalid --color never analyze
printf 'exit=%s\n' "$?"

Actual result: exit code 2, followed by Error: missing required flag --input .... No prompt is shown and the piped answers are not consumed.

Expected result: when --interactive is explicitly enabled, non-TTY stdin should use the documented line-prompt fallback. The default and --no-interactive behavior should remain non-interactive.

Evidence

Suggested fix

Align the activation policy with the documented behavior and add a subprocess/pipe contract test. Please preserve the existing TTY interface, default non-interactive behavior, and --no-interactive behavior.

Actual vs expected behavior:

No response

Any other information you'd like to share?

No response

Lingua principale
Go
Stelle
3k
Fork
219
Merge medio
2g 2h
PR unite (30g)
66

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di google-gemini/gemini-api-cli

Tutte le issue di google-gemini/gemini-api-cli

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.