console-rs / console-rs/console
Piping data via STDIN into executable makes text prompts not work
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.2k
- Forks
- 144
- Avg merge
- 8h 24m
- Merged PRs (30d)
- 4
Description
Issue
As soon as I populate the STDIN pipe to my program with any data, the text prompts won't work properly.
Context
I have a binary that does text processing (https://github.com/replicadse/complate).
In the past, the configuration for the template was loaded via a configuration file. I have added a feature with which one should be able to pipe the configuration string directly into the print command.
Behaviour
dialoguer::Input::new().allow_empty(false).with_prompt("some text").interact()
When specifying allow_empty(false), the terminal flickers and shows weird behaviour. I can not enter text nor can I do anything else than Ctrl+C exit.
When specifying allow_empty(true), the data result string is empty.
References
Here you can see me reading the data from STDIN:
https://github.com/replicadse/complate/pull/10/files#diff-c5354523dab7ee14c84278715c952cb7e302af46f5c8372b94375b36f003b93eR138
Here you can see me using dialoguer:
https://github.com/replicadse/complate/blob/master/src/render/mod.rs#L174
Contributor guide
No contributing guide indexed for this repository
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 by reproducing the interaction described with dialoguer::Input and piped STDIN, using the complate references to understand how STDIN is consumed before the prompt at src/render/mod.rs:174. Inspect the console input and terminal handling involved, then verify that piped data remains available while interactive text prompts accept input normally.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100