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

[Feature Request] Ability to map choose values to keys #43

Closed
dector opened this issue Jul 30, 2022 · 4 comments
Closed

[Feature Request] Ability to map choose values to keys #43

dector opened this issue Jul 30, 2022 · 4 comments

Comments

@dector
Copy link

dector commented Jul 30, 2022

This is not a suggested syntax - snippet if purely for demonstration purposes:

gum choose --with-mapping "foo:My foo value" "bar:My bar value"

switch $result
    "foo" -> ...
    "bar" -> ...

Motivation: in many cases it would be nice to use some id-values for choose command instead of duplicating human-readable values two times: in command and in control script.

P.S. Thanks for the tool - it's awesome. Yesterday I integrated in some of my fish functions for administration and it's so much nicer to use now!

@maaslalani
Copy link
Member

maaslalani commented Jul 30, 2022

Hey!

P.S. Thanks for the tool - it's awesome. Yesterday I integrated in some of my fish functions for administration and it's so much nicer to use now!

Thank you for the kind words!

You can actually accomplish this with pure shell scripting, here is an example:

https://github.com/charmbracelet/gum/blob/main/examples/filter-key-value.sh

export LIST=$(cat <<END
Cow:Moo
Cat:Meow
Dog:Woof
END)

ANIMAL=$(echo "$LIST" | cut -d':' -f1 | gum filter)
SOUND=$(echo "$LIST" | grep $ANIMAL | cut -d':' -f2)

echo "The $ANIMAL goes $SOUND"

This allows everyone to use whatever delimiters they want and makes it much more flexible instead of prescribing a solution with flags inside of gum.

@maaslalani maaslalani closed this as not planned Won't fix, can't repro, duplicate, stale Jul 30, 2022
@dector
Copy link
Author

dector commented Jul 30, 2022

😢 That's not really the same and MUCH LESS readable. But thanks for the suggestion.

@maaslalani
Copy link
Member

That's not really the same

Hmm, I may have misinterpreted your original example then. Could you elaborate on what you are trying to do and I can try and put together a more readable example for you?

@dector
Copy link
Author

dector commented Aug 2, 2022

No, it seems that your interpretation was correct. :)

However, gum choose doesn't have search bar and have multi-selection and it "feels" different than gum filter.

I'll implement new behavior for myself anyway and then I can show the code - maybe you'll reconsider. :)

Thanks.

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

No branches or pull requests

2 participants