fix: choose prefixes and pink gum text

This commit is contained in:
Maas Lalani 2022-07-14 10:37:22 -04:00
parent 0f4b98c2ad
commit 5a1195dda5
No known key found for this signature in database
GPG key ID: 5A6ED5CBF1A0A000
3 changed files with 12 additions and 8 deletions

View file

@ -87,9 +87,10 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
} }
case "enter": case "enter":
m.quitting = true m.quitting = true
// Select the item on which they've hit enter if it falls within // If the user hasn't selected any items in a multi-select.
// the limit. // Then we select the item that they have pressed enter on. If they
if m.numSelected < m.limit { // have selected items, then we simply return them.
if m.numSelected < 1 {
m.items[m.index].selected = true m.items[m.index].selected = true
} }
return m, tea.Quit return m, tea.Quit

View file

@ -10,9 +10,9 @@ type Options struct {
NoLimit bool `help:"Pick unlimited number of options (ignores limit)" group:"Selection"` NoLimit bool `help:"Pick unlimited number of options (ignores limit)" group:"Selection"`
Height int `help:"Height of the list" default:"10"` Height int `help:"Height of the list" default:"10"`
Cursor string `help:"Prefix to show on item that corresponds to the cursor position" default:"> "` Cursor string `help:"Prefix to show on item that corresponds to the cursor position" default:"> "`
CursorPrefix string `help:"Prefix to show on the cursor item (hidden if limit is 1)" default:"• "` CursorPrefix string `help:"Prefix to show on the cursor item (hidden if limit is 1)" default:"[] "`
SelectedPrefix string `help:"Prefix to show on selected items (hidden if limit is 1)" default:"✕ "` SelectedPrefix string `help:"Prefix to show on selected items (hidden if limit is 1)" default:"[] "`
UnselectedPrefix string `help:"Prefix to show on selected items (hidden if limit is 1)" default:" "` UnselectedPrefix string `help:"Prefix to show on selected items (hidden if limit is 1)" default:"[ ] "`
CursorStyle style.Styles `embed:"" prefix:"cursor." set:"defaultForeground=212" set:"name=indicator"` CursorStyle style.Styles `embed:"" prefix:"cursor." set:"defaultForeground=212" set:"name=indicator"`
ItemStyle style.Styles `embed:"" prefix:"item." hidden:"" set:"defaultForeground=255" set:"name=item"` ItemStyle style.Styles `embed:"" prefix:"item." hidden:"" set:"defaultForeground=255" set:"name=item"`
SelectedItemStyle style.Styles `embed:"" prefix:"selected." set:"defaultForeground=212" set:"name=selected item"` SelectedItemStyle style.Styles `embed:"" prefix:"selected." set:"defaultForeground=212" set:"name=selected item"`

View file

@ -1,18 +1,21 @@
package main package main
import ( import (
"fmt"
"github.com/alecthomas/kong" "github.com/alecthomas/kong"
"github.com/charmbracelet/lipgloss" "github.com/charmbracelet/lipgloss"
"github.com/muesli/termenv" "github.com/muesli/termenv"
) )
var bubbleGumPink = lipgloss.NewStyle().Foreground(lipgloss.Color("212"))
func main() { func main() {
lipgloss.SetColorProfile(termenv.ANSI256) lipgloss.SetColorProfile(termenv.ANSI256)
gum := &Gum{} gum := &Gum{}
ctx := kong.Parse( ctx := kong.Parse(
gum, gum,
kong.Name("gum"), kong.Description(fmt.Sprintf("Tasty bubble %s for your shell.", bubbleGumPink.Render("gum"))),
kong.Description("Tasty Bubble Gum for your shell."),
kong.UsageOnError(), kong.UsageOnError(),
kong.ConfigureHelp(kong.HelpOptions{ kong.ConfigureHelp(kong.HelpOptions{
Compact: true, Compact: true,