Skip to content

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

Merged
caarlos0 merged 1 commit intomainfrom
filter-select
Dec 13, 2024
Merged

feat(filter): allow to pre-select items with --selected#777
caarlos0 merged 1 commit intomainfrom
filter-select

Conversation

@caarlos0
Copy link
Copy Markdown
Contributor

closes #593

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

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
Copy Markdown
Contributor 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
Copy Markdown
Contributor

LOL @caarlos0 thank you for catching that! 🙏

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

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
Copy Markdown
Contributor 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 <caarlos0@users.noreply.github.com>
@caarlos0
Copy link
Copy Markdown
Contributor 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