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

Idea: enum prompts #8

Open
tennox opened this issue Nov 27, 2023 · 0 comments
Open

Idea: enum prompts #8

tennox opened this issue Nov 27, 2023 · 0 comments

Comments

@tennox
Copy link

tennox commented Nov 27, 2023

I'm not sure if possible to do it in a similarily magic way as the rest of your code, but something like this would be great:

Failed to foo, do you want to continue? ( y[es] / n[o] / r[etry] )

With code similar to this (using e.g. strum crate for enum introspection)

#[derive(Debug, EnumIter)]
pub enum YNR {
    Yes,
    No,
    Retry,
}
loop {
    match prompt("Failed to foo, do you want to continue?")? {
                YNR::Yes => ..
                YNR::No => ..
                YNR::Retry => continue,
    }
}
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

1 participant