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

feat: add gum helper for choose dialogs #173

Merged
merged 9 commits into from
Dec 21, 2023
Merged

feat: add gum helper for choose dialogs #173

merged 9 commits into from
Dec 21, 2023

Conversation

HikariKnight
Copy link
Member

This should help start the process of addressing #148 as it will let us provide basic replacement for gum on systems that lack it with minimal options which in turn lets us shrink down the amount of just commands we have greatly.

Currently it only does choose dialogs, but before merging i want to implement the confirm dialog too.
Return values will be identical to what you would expect from gum so in the most basic use cases it will be a 1:1 drop in, assuming you do not need anything more fancy than the defaults from gum.

@HikariKnight
Copy link
Member Author

HikariKnight commented Dec 20, 2023

Current implementation of ugum supports the choose and confirm verbs
if a command was to be gum choose --cursor="| " "ace of spades" "king of hearts" "5 of diamond" in a just recipe, this can now be replaced with ugum choose --cursor="| " "ace of spades" "king of hearts" "5 of diamond" and ugum will ignore any arguments starting with - and only focus on the the basics, which is providing a choice selection for the user, if ugum detects that the gum binary is present, it will pass all arguments to gum for a more fancy output.
The return values in STDOUT will match what you would expect from using gum if it was installed and it will return the option the user selected.
image
image

ugum confirm does the same for confirm dialogs and would be the equivalent to gum confirm.
To change the default prompt just supply one after confirm like ugum confirm "Do you want to build a rocket ship?"
exit code will be 0 if yes, 1 if no. This matches the output from gum
image

@HikariKnight
Copy link
Member Author

Is there any more changes i need to do to the spec file since it says it failed to build due to the ugum file missing in the log? 🤔

@HikariKnight HikariKnight marked this pull request as ready for review December 20, 2023 17:07
bsherman
bsherman previously approved these changes Dec 20, 2023
Copy link
Contributor

@bsherman bsherman left a comment

Choose a reason for hiding this comment

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

Seems reasonable.

@HikariKnight
Copy link
Member Author

fzf is now being used as fallback handler if gum is not available and will look like this
image

if no supported handler is provided in $MENU environment variable and fzf is not available, it will use basic bash to generate the choice selection and the confirm prompts

@KyleGospo
Copy link
Member

This looks great!!

@castrojo castrojo enabled auto-merge December 21, 2023 00:03
@bsherman bsherman self-requested a review December 21, 2023 00:03
@bsherman bsherman dismissed their stale review December 21, 2023 00:04

Will review when ready.

@HikariKnight
Copy link
Member Author

HikariKnight commented Dec 21, 2023

Ok, as long as no more needed changes get requested, this is now feature complete for initial release.
There were some requests to use fzf after the PR got opened for review.
And since fzf is included in the images, it is a perfect alternative for gum for the images without gum.

The generic bash alternatives are still there in case a user makes a custom image and removes fzf and gum for whatever reason.

Any more changes will be done at a later date with their own PR and if support for more menu handlers is desired then it can be added at a later date by people familiar with the said menu handlers (dmenu, rofi, wofi, rofi-wayland, etc)

@castrojo castrojo added this pull request to the merge queue Dec 21, 2023
Merged via the queue into main with commit a20eb9c Dec 21, 2023
2 checks passed
@castrojo castrojo deleted the toggle-helper branch December 21, 2023 04:48
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.

4 participants