pallets / pallets/click

click.confirm fails when piping input

Open
#1,370 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

prompt
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

Open the contributing guide

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.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.