console-rs / dialoguer

Rust utility library for nice command line prompts and similar things
MIT License
1.31k stars 143 forks source link

Make inputs fail if not connected to a terminal #261

Closed mitsuhiko closed 1 year ago

mitsuhiko commented 1 year ago

Fixes #229

Fixes #148

Follows #260

jyn514 commented 1 year ago

What is the intended way to use dialoguer for non-interactive Term objects? I would like to test my application by feeding it a Term::read_write_pair that I run assertions on, but this makes it impossible because it just immediately exits with an error instead of reading from the file.

jyn514 commented 1 year ago

I think the correct thing to do is to fix this upstream in console by reading from the read half of the pair instead of hard-coding Key::Unknown: https://github.com/console-rs/console/issues/117

Looks like https://github.com/console-rs/console/pull/173 was intended to fix that but hasn't gotten any reviews ...