Closed ryan-timothy-albert closed 7 months ago
Hi, this is already possible on the latest huh@main
! Introduced in:
We'll do a release soon which will make it available more widely but to try it out:
go get -u github.com/charmbracelet/huh@main
And then on your Input
fields you can attach Suggestions
:
huh.NewInput().Suggestions([]string{"foo", "bar", "baz"})
Awesome I'll try that out thank you!
Wondering if there is a general estimate on when that next release will be? Not urgent
Hey @ryan-timothy-albert! It should be next week!
Hey @maaslalani
Harcoded suggestions are working well. One follow up question we have that's come from our users is if there are plans to hook into more dynamic autocompletion. i.e. someone starts to type ../open
we can suggest files in that directory that start with open.
Hey @ryan-timothy-albert, thanks for re-opening this issue. We want to create a system in huh that lets you re-evaluate any part of the form based on the user input as well.
This should encompass passing in new suggestions to Suggestions
.
Hi @maaslalani
Thanks for the response. We do use the WithHideFunc internally. I'm totally following how this can help us populate suggestions based on live user input to a field though.
Hey @maaslalani
So currently we are supporting dynamic autocomplete with a fork of the library see the following here.
Here is the callback function that we use pass into certain input fields.
I recognize there are some risks to exposing a callback like this from field_input especially if the user implements it incorrectly. I'm wondering if you'd be open to something like this in the main huh library, or perhaps a different approach to the problem.
I'm wondering if it's possible to support tab completion for input fields. Ideally it would be possible to use tab completion when entering values like it is outside of the form.
It may already be possible to configure this and I am missing something.
Thanks in Advance!