From 5a1195dda584fa33f976c7a8cd43df6cf907db48 Mon Sep 17 00:00:00 2001 From: Maas Lalani Date: Thu, 14 Jul 2022 10:37:22 -0400 Subject: [PATCH] fix: choose prefixes and pink `gum` text --- choose/choose.go | 7 ++++--- choose/options.go | 6 +++--- main.go | 7 +++++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/choose/choose.go b/choose/choose.go index 61445b1..9f2e9c1 100644 --- a/choose/choose.go +++ b/choose/choose.go @@ -87,9 +87,10 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } case "enter": m.quitting = true - // Select the item on which they've hit enter if it falls within - // the limit. - if m.numSelected < m.limit { + // If the user hasn't selected any items in a multi-select. + // Then we select the item that they have pressed enter on. If they + // have selected items, then we simply return them. + if m.numSelected < 1 { m.items[m.index].selected = true } return m, tea.Quit diff --git a/choose/options.go b/choose/options.go index e2702f8..f5edf23 100644 --- a/choose/options.go +++ b/choose/options.go @@ -10,9 +10,9 @@ type Options struct { NoLimit bool `help:"Pick unlimited number of options (ignores limit)" group:"Selection"` Height int `help:"Height of the list" default:"10"` 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:"• "` - 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:" "` + 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:"[✕] "` + 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"` 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"` diff --git a/main.go b/main.go index 862a268..3f7d339 100644 --- a/main.go +++ b/main.go @@ -1,18 +1,21 @@ package main import ( + "fmt" + "github.com/alecthomas/kong" "github.com/charmbracelet/lipgloss" "github.com/muesli/termenv" ) +var bubbleGumPink = lipgloss.NewStyle().Foreground(lipgloss.Color("212")) + func main() { lipgloss.SetColorProfile(termenv.ANSI256) gum := &Gum{} ctx := kong.Parse( gum, - kong.Name("gum"), - kong.Description("Tasty Bubble Gum for your shell."), + kong.Description(fmt.Sprintf("Tasty bubble %s for your shell.", bubbleGumPink.Render("gum"))), kong.UsageOnError(), kong.ConfigureHelp(kong.HelpOptions{ Compact: true,