click.confirm fails when piping input
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 17.7k
- Forks
- 2.3k
- Avg merge
- 1d 30m
- Merged PRs (30d)
- 18
Description
I string a lot of my programs together through piping, but some of them work best with confirmation prompting. However, if I pipe program A's output into program B and B asks for confirmation, click.confirm will not be able to get keyboard input since stdin is the pipe, not the terminal.
It seems that a work around would be to use click.getchar, which uses the terminal no matter what, but this would mean a few lines of code + an if statement to get the the same functionality.
Would it be possible to get click.confirm to always get input from the terminal? Or at least include an option for that?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at click.confirm and compare its input handling with click.getchar, which the issue identifies as terminal-based. Determine whether confirmation should always read from the terminal or expose an option, then add coverage for confirmation when stdin is a pipe; done means piped commands can still receive confirmation input.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100