charmbracelet / huh

Build terminal forms and prompts 🤷🏻‍♀️
MIT License
3.72k stars 94 forks source link

feat(form): implement WithTimeout #276

Closed Delta456 closed 1 month ago

Delta456 commented 1 month ago

Implements https://github.com/charmbracelet/huh/issues/166

Demonstration

image

maaslalani commented 1 month ago

Hey @Delta456, thanks for the good work: I don't have push access to your repo so can you cherry pick the following commit in this PR and then we can merge:

This commit just adds a specific error for timeouts and handles the case when timeout is not set.

Delta456 commented 1 month ago

Hey @Delta456, thanks for the good work: I don't have push access to your repo so can you cherry pick the following commit in this PR and then we can merge:

* [8ebd7d6](https://github.com/charmbracelet/huh/commit/8ebd7d69b5986894df066ad6d1ad3a096b656dbf)

This commit just adds a specific error for timeouts and handles the case when timeout is not set.

Done!

Forgot to consider the latter case

korpa commented 3 weeks ago

@Delta456 Thank you very much. I tested it and I really like it. I have two ideas to improve it: 1) Show a countdown 2) Would it be possible to change the behaviour a little bit? Stop timeout as soon as a key is pressed. Otherwise it could happen, that the form aborts while I'm still filling it out. Especially in bigger forms.

What do you think?

Delta456 commented 3 weeks ago

@Delta456 Thank you very much. I tested it and I really like it. I have two ideas to improve it: 1) Show a countdown 2) Would it be possible to change the behaviour a little bit? Stop timeout as soon as a key is pressed. Otherwise it could happen, that the form aborts while I'm still filling it out. Especially in bigger forms.

What do you think?

Hi, thanks for the appreciation! I can try adding more if @maaslalani agrees too

  1. It's a good idea to show a countdown. What would be the measured time stamp?

  2. Exiting the timeout would beat the whole purpose of having a timeout. I feel extending the timeout would be better in bigger forms.