Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single state prompt #249

Open
Freyja-moth opened this issue Apr 30, 2024 · 2 comments
Open

Single state prompt #249

Freyja-moth opened this issue Apr 30, 2024 · 2 comments

Comments

@Freyja-moth
Copy link

Freyja-moth commented Apr 30, 2024

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.

@Freyja-moth
Copy link
Author

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.

@mikaelmello
Copy link
Owner

mikaelmello commented Sep 29, 2024

I like that idea.

Currently, you can achieve that exact thing with this:

let _ = Text::new("Something's gone wrong, retrying...")
    .prompt()
    .unwrap();

It will stop, listen to any input and proceed on enter, and then you just discard what was written.

But if you're looking for something that will advance on any keyboard input, then yeah we'll need something new

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants