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

Adding alert as new message type #288

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sluedecke
Copy link

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 #287

@pksunkara
Copy link
Collaborator

Why can't confirm be used?

@sluedecke
Copy link
Author

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.

Copy link
Collaborator

@pksunkara pksunkara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding a new prompt, can you please modify the confirm prompt with an extra option?

@sluedecke
Copy link
Author

sluedecke commented Oct 30, 2023

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:

  • Clearer API - it is focussed on the use case alert only. How to interpret the options report, default, show_default and wait_for_newline for an alert?
  • Clearer code - adding it to confirm would make the routines interact_on, theme/mod.rs::format_confirm_prompt and theme/colorful.rs::format_confirm_prompt more complex.

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

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

Successfully merging this pull request may close these issues.

2 participants