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

Open
#246 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
67/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
cli, testing

Research direction

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.

Written by the indexing model from the issue text.

Description

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

Dominant language
Go
Stars
3k
Forks
219
Avg merge
2d 2h
Merged PRs (30d)
66

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from google-gemini/gemini-api-cli

All issues in google-gemini/gemini-api-cli

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.