Skip to content

feat(filter): allow to pre-select items with --selected #777

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

Merged
merged 1 commit into from
Dec 13, 2024

Conversation

caarlos0
Copy link
Member

closes #593

@caarlos0 caarlos0 self-assigned this Dec 13, 2024
@caarlos0 caarlos0 merged commit 966237b into main Dec 13, 2024
14 checks passed
@caarlos0 caarlos0 deleted the filter-select branch December 13, 2024 19:59
@bashbunni
Copy link
Member

Hey just tried this with the following options on main and didn't get the expected result. In both cases, the filtered results are all unselected

# Select js
platforms=$(echo "js|android|ios" | gum filter --input-delimiter="|" --no-limit --output-delimiter=",") --selected="js"

# Select all
platforms=$(echo "js|android|ios" | gum filter --input-delimiter="|" --no-limit --output-delimiter=",") --selected="*"

# This one worked
echo "Applications\nLibrary\nDownloads" | gum filter --selected="Downloads"

My guess is it's not working when there is a --no-limit flag on the filter command.

@caarlos0
Copy link
Member Author

Hey just tried this with the following options on main and didn't get the expected result. In both cases, the filtered results are all unselected

# Select js
platforms=$(echo "js|android|ios" | gum filter --input-delimiter="|" --no-limit --output-delimiter=",") --selected="js"

# Select all
platforms=$(echo "js|android|ios" | gum filter --input-delimiter="|" --no-limit --output-delimiter=",") --selected="*"

# This one worked
echo "Applications\nLibrary\nDownloads" | gum filter --selected="Downloads"

My guess is it's not working when there is a --no-limit flag on the filter command.

the --selected flag is outside the ():

# Select js
platforms=$(echo "js|android|ios" | gum filter --input-delimiter="|" --no-limit --output-delimiter="," --selected="js")

# Select all
platforms=$(echo "js|android|ios" | gum filter --input-delimiter="|" --no-limit --output-delimiter="," --selected="*")

# This one worked
echo "Applications\nLibrary\nDownloads" | gum filter --selected="Downloads"

@bashbunni
Copy link
Member

LOL @caarlos0 thank you for catching that! 🙏

@bashbunni bashbunni added this to the v0.15.0 milestone Jan 12, 2025
@bashbunni
Copy link
Member

merp, for some reason --selected=* isn't working anymore :/ tried your working example again just to confirm the example in the release notes would work, but for some reason it's not selecting all of the elements by default when it opens the filter view

echo "js|android|ios" | gum filter --input-delimiter="|" --no-limit --output-delimiter="," --selected="*"
image

@caarlos0
Copy link
Member Author

ouch, true, also just noticed that tab on the last item is broken

caarlos0 added a commit that referenced this pull request Jan 12, 2025
refs #777 (comment)

Signed-off-by: Carlos Alexandro Becker <[email protected]>
@caarlos0
Copy link
Member Author

fixed on main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add preselected options when using filter command
2 participants