console-rs / dialoguer

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

Adding alert as new message type #288

Open sluedecke opened 11 months ago

sluedecke commented 11 months ago

In case of an unexpected events, I would love to display a warning to the user, which simply needs to be "confirmed" for the programm to move on.

The workaround I use is a selection with "OK" as single option, but this is a bit hacky.

I kindly request to add alert as a new interaction option to dialoguer. One can use the pull request, but I probably messed the return types up ...

obsoletes https://github.com/console-rs/dialoguer/issues/287

pksunkara commented 11 months ago

Why can't confirm be used?

sluedecke commented 11 months ago

I tried, but it appeared to me that all ways to use Confirm present the user with some kind of choice. There is always the y/n rendered and I am looking for an alert which can only be acknowleged.

This can be done with Confirm and setting a default, but having the 'y/n' suggests that there is a choice if there actually is none.

sluedecke commented 10 months ago

Sure. But I wonder if that would introduce a lot of "if-clauses" into the code making it more complex than needed. Right now I think a new prompt has these advantages:

Probably it is just a mattter of coding style, what do you think?