-
Notifications
You must be signed in to change notification settings - Fork 357
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
gum choose: Option to not ask when there is no choice #396
Comments
Hey @vt-alt do you mind providing me with a bit more context here? I'm hoping to clarify the use case for this feature and why it is better than whatever current workaround there is for this? If you could provide some examples with code/scripts that would be really helpful to see how this feature changes the UX. @kennyp I saw your PR, so if you would like to chime in on this as well that would be great :) |
I have interface that queries various info about RPM package(s), and by the selectors there could be several packages (like different repositories (old or new) or different architectures) or just one package. It would be just handy when there is single package to not request users to select it. Workaround is to count lines before gum call and to skip it. For a more detailed example, from a single RPM source - one or several binary packages could be built (for example |
My thoughts are the same as @vt-alt. I have a few places where I'm getting a list of candidates by polling an API, and if there's only one candidate, it's nice to select it and move to confirm the following action. In apps=($(fetch_from API_URL))
if [ "${#apps[@]}" = "1" ]; then
chosen="${apps[0]}"
else
chosen=$(echo ${apps[@]} | tr ' ' '\n' | gum choose)
fi And with this feature it's just: chosen=$(fetch_from API_URL | gum choose --select-if-one) |
Any thoughts @bashbunni? |
Btw,
|
Sorry about the delay on this one! Merged! |
Is your feature request related to a problem? Please describe.
When using dynamic choice list in
gum choose
, sometimes it's no need to ask user for choice if there's just one option. So in that case it would be useful to have option to skip asking user and just return that single value.Describe the solution you'd like
Like
gum choose --no-ask-if-no-choice one
would just returnone
immediately.Describe alternatives you've considered
Well alternative is to script
gum
call, but such option would be easier for users.Additional context
It's also important that this should not be enabled by default, because user may expect interactive step and may press
enter
in advance and if step is skipped wrong choice could be selected,The text was updated successfully, but these errors were encountered: