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(multiselect): contextual 'select all' help text #342

Merged
merged 2 commits into from
Aug 6, 2024

Conversation

meowgorithm
Copy link
Member

This revision changes the "toggle all" help text to "select all" and "select none" depending on what action will be performed.

select-all-select-none.mov

Here's the source code for the above example:

package main

import (
	"fmt"
	"os"

	"github.com/charmbracelet/huh"
)

func main() {
	prompt := huh.NewMultiSelect[int]().
		Title("Choose stuff, will ya?").
		Height(10).
		Options(
			huh.NewOption("Uno", 1),
			huh.NewOption("Due", 2),
			huh.NewOption("Tre", 3),
			huh.NewOption("Quattro", 4),
			huh.NewOption("Cinque", 5),
			huh.NewOption("Sei", 6),
			huh.NewOption("Sette", 7),
			huh.NewOption("Otto", 8),
			huh.NewOption("Nove", 9),
			huh.NewOption("Dieci", 10),
		)

	f := huh.NewForm(huh.NewGroup(prompt))

	if err := f.Run(); err != ni l {
		fmt.Fprint(os.Stderr, "Uh oh: ", err)
		os.Exit(1)
	}
}

Either 'select all' or 'select none' will appear in the help depending on the
action that will be performed.
Copy link
Member

@caarlos0 caarlos0 left a comment

Choose a reason for hiding this comment

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

noice

@maaslalani
Copy link
Contributor

I wonder if we should add the number of options that will be selected in the help?

"select all 10 options"

This would be especially helpful with filtered lists.

@meowgorithm
Copy link
Member Author

That's a really good idea, though I do worry about it getting too long (at 0:08 in the video help is getting quite long).

@caarlos0 caarlos0 merged commit b7436a7 into main Aug 6, 2024
40 checks passed
@caarlos0 caarlos0 deleted the select-all-select-none branch August 6, 2024 00:52
renovate bot referenced this pull request in jippi/dottie Aug 23, 2024
….mod (#85)

[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [github.com/charmbracelet/huh](https://togithub.com/charmbracelet/huh)
| `v0.5.2` -> `v0.5.3` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fcharmbracelet%2fhuh/v0.5.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fcharmbracelet%2fhuh/v0.5.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fcharmbracelet%2fhuh/v0.5.2/v0.5.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fcharmbracelet%2fhuh/v0.5.2/v0.5.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>charmbracelet/huh (github.com/charmbracelet/huh)</summary>

###
[`v0.5.3`](https://togithub.com/charmbracelet/huh/releases/tag/v0.5.3)

[Compare
Source](https://togithub.com/charmbracelet/huh/compare/v0.5.2...v0.5.3)

### Crushin’ bugs

This release fixes a buncha bugs in Huh and
[Gum](https://togithub.com/charmbracelet/gum) alike. Gum users, stay
tuned for an update later today.

#### What's Changed

##### Fixed

- fix: group varying heights by
[@&#8203;bashbunni](https://togithub.com/bashbunni) in
[https://github.com/charmbracelet/huh/pull/350](https://togithub.com/charmbracelet/huh/pull/350)
- fix: group size when height is 0 by
[@&#8203;caarlos0](https://togithub.com/caarlos0) in
[https://github.com/charmbracelet/huh/pull/363](https://togithub.com/charmbracelet/huh/pull/363)
- fix(filepicker): not closing on close by
[@&#8203;caarlos0](https://togithub.com/caarlos0) in
[https://github.com/charmbracelet/huh/pull/323](https://togithub.com/charmbracelet/huh/pull/323)
- fix(select): wrapping selects by
[@&#8203;caarlos0](https://togithub.com/caarlos0) in
[https://github.com/charmbracelet/huh/pull/324](https://togithub.com/charmbracelet/huh/pull/324)
- fix(select): select all/none by
[@&#8203;caarlos0](https://togithub.com/caarlos0) in
[https://github.com/charmbracelet/huh/pull/325](https://togithub.com/charmbracelet/huh/pull/325)
- fix(multiselect): contextual 'select all' help text by
[@&#8203;meowgorithm](https://togithub.com/meowgorithm) in
[https://github.com/charmbracelet/huh/pull/342](https://togithub.com/charmbracelet/huh/pull/342)
- fix(spinner): light color in title by
[@&#8203;hyorigo](https://togithub.com/hyorigo) in
[https://github.com/charmbracelet/huh/pull/346](https://togithub.com/charmbracelet/huh/pull/346)
- fix (multiselect): set filterable not working by
[@&#8203;caarlos0](https://togithub.com/caarlos0) in
[https://github.com/charmbracelet/huh/pull/335](https://togithub.com/charmbracelet/huh/pull/335)
- fix(lint): golangci-lint issues by
[@&#8203;caarlos0](https://togithub.com/caarlos0) in
[https://github.com/charmbracelet/huh/pull/378](https://togithub.com/charmbracelet/huh/pull/378)

#### Other Stuff

- chore: update codeowners by
[@&#8203;caarlos0](https://togithub.com/caarlos0) in
[https://github.com/charmbracelet/huh/pull/379](https://togithub.com/charmbracelet/huh/pull/379)
- refactor: use a selector type to select items by
[@&#8203;aymanbagabas](https://togithub.com/aymanbagabas) in
[https://github.com/charmbracelet/huh/pull/328](https://togithub.com/charmbracelet/huh/pull/328)
- refactor: make item selector into a slice container by
[@&#8203;aymanbagabas](https://togithub.com/aymanbagabas) in
[https://github.com/charmbracelet/huh/pull/334](https://togithub.com/charmbracelet/huh/pull/334)

#### New Contributors

- [@&#8203;bashbunni](https://togithub.com/bashbunni) made their first
contribution in
[https://github.com/charmbracelet/huh/pull/350](https://togithub.com/charmbracelet/huh/pull/350)
- [@&#8203;hyorigo](https://togithub.com/hyorigo) made their first
contribution in
[https://github.com/charmbracelet/huh/pull/346](https://togithub.com/charmbracelet/huh/pull/346)

**Full Changelog**:
charmbracelet/huh@v0.5.2...v0.5.3

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "* */1 * * *" (UTC), Automerge - At
any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View the
[repository job log](https://developer.mend.io/github/jippi/dottie).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4yNi4xIiwidXBkYXRlZEluVmVyIjoiMzguMjYuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiZGVwZW5kZW5jaWVzIl19-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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.

3 participants