mikaelmello / inquire

A Rust library for building interactive prompts

Home Page:https://docs.rs/inquire

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Single state prompt

Freyja-moth opened this issue · comments

Is your feature request related to a problem? Please describe.
Sometime when I use inquire I want to display text, without taking input from the user.

Describe the solution you'd like
Perhaps a Speech (probably a bad name but it's the only one I could come up with) struct that would display the text as specified by new and would then wait for the user to hit enter before continuing.

// Doesn't require any value to be passed in, but will wait until the user acknowledge it  
Speech::new("Something's gone wrong, retrying").prompt().unwrap();

Describe alternatives you've considered
Something with a similar effect can be achieved using Confirm with a default value, but that will show (Y/n) after the prompt which would imply that there are multiple ways you could respond to it which is not ideal.

It might also be possible to do this by printing something then waiting for the user to press enter, like this

println!("Something's gone wrong, retrying");
let stdin = io::stdin();
let mut buf = String::new();

stdin.read_line(&mut buf).unwrap();

but that feels very clunky, doesn't have the fancy display that inquire has which would make it stand out and, I would just prefer to stay within inquire for displaying stuff where possible, if I'm using it in a project.

It may also be nice to make it so that you can turn on/off the prompt so that you could have it wait for user input or just display the text and get right back to running things depending on what you need.