From b0f441318812e547194face9cd8804fb0030e052 Mon Sep 17 00:00:00 2001 From: Mikael Fangel <34864484+MikaelFangel@users.noreply.github.com> Date: Thu, 25 Jul 2024 13:57:35 +0000 Subject: [PATCH 001/198] chore: remove explicitly defined max functions (#613) * filter: remove max function * timeout: remove max function --- filter/filter.go | 7 ------- timeout/options.go | 7 ------- 2 files changed, 14 deletions(-) diff --git a/filter/filter.go b/filter/filter.go index 38c25f9..1b827eb 100644 --- a/filter/filter.go +++ b/filter/filter.go @@ -332,10 +332,3 @@ func clamp(min, max, val int) int { } return val } - -func max(a, b int) int { - if a > b { - return a - } - return b -} diff --git a/timeout/options.go b/timeout/options.go index 9986835..8dae2d5 100644 --- a/timeout/options.go +++ b/timeout/options.go @@ -46,10 +46,3 @@ func Tick(timeoutValue time.Duration, data interface{}) tea.Cmd { func Str(timeout time.Duration) string { return fmt.Sprintf(" (%d)", max(0, int(timeout.Seconds()))) } - -func max(a, b int) int { - if a > b { - return a - } - return b -} From 8422c49018116886ae23356c2101c9f7076c865b Mon Sep 17 00:00:00 2001 From: Piero Lescano Date: Thu, 25 Jul 2024 09:02:56 -0500 Subject: [PATCH 002/198] feat(filter): Add cyclic navigation (#483) --- filter/filter.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/filter/filter.go b/filter/filter.go index 1b827eb..92b5677 100644 --- a/filter/filter.go +++ b/filter/filter.go @@ -255,29 +255,41 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { func (m *model) CursorUp() { if m.reverse { - m.cursor = clamp(0, len(m.matches)-1, m.cursor+1) + m.cursor = (m.cursor + 1) % len(m.matches) if len(m.matches)-m.cursor <= m.viewport.YOffset { - m.viewport.SetYOffset(len(m.matches) - m.cursor - 1) + m.viewport.LineUp(1) + } + if len(m.matches)-m.cursor > m.viewport.Height+m.viewport.YOffset { + m.viewport.SetYOffset(len(m.matches) - m.viewport.Height) } } else { - m.cursor = clamp(0, len(m.matches)-1, m.cursor-1) + m.cursor = (m.cursor - 1 + len(m.matches)) % len(m.matches) if m.cursor < m.viewport.YOffset { - m.viewport.SetYOffset(m.cursor) + m.viewport.LineUp(1) + } + if m.cursor >= m.viewport.YOffset+m.viewport.Height { + m.viewport.SetYOffset(len(m.matches) - m.viewport.Height) } } } func (m *model) CursorDown() { if m.reverse { - m.cursor = clamp(0, len(m.matches)-1, m.cursor-1) + m.cursor = (m.cursor - 1 + len(m.matches)) % len(m.matches) if len(m.matches)-m.cursor > m.viewport.Height+m.viewport.YOffset { m.viewport.LineDown(1) } + if len(m.matches)-m.cursor <= m.viewport.YOffset { + m.viewport.GotoTop() + } } else { - m.cursor = clamp(0, len(m.matches)-1, m.cursor+1) + m.cursor = (m.cursor + 1) % len(m.matches) if m.cursor >= m.viewport.YOffset+m.viewport.Height { m.viewport.LineDown(1) } + if m.cursor < m.viewport.YOffset { + m.viewport.GotoTop() + } } } From 046a4d361eb12ffc0fd1b7ea5fec697ba1fe118e Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Thu, 25 Jul 2024 13:12:30 -0400 Subject: [PATCH 003/198] fix: use 0 as default width (#634) * fix: use 0 as default width Signed-off-by: Carlos Alexandro Becker * fix: filter width --------- Signed-off-by: Carlos Alexandro Becker --- filter/options.go | 2 +- input/options.go | 2 +- write/options.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/filter/options.go b/filter/options.go index 489c734..f4d57cb 100644 --- a/filter/options.go +++ b/filter/options.go @@ -29,7 +29,7 @@ type Options struct { Prompt string `help:"Prompt to display" default:"> " env:"GUM_FILTER_PROMPT"` PromptStyle style.Styles `embed:"" prefix:"prompt." set:"defaultForeground=240" envprefix:"GUM_FILTER_PROMPT_"` PlaceholderStyle style.Styles `embed:"" prefix:"placeholder." set:"defaultForeground=240" envprefix:"GUM_FILTER_PLACEHOLDER_"` - Width int `help:"Input width" default:"20" env:"GUM_FILTER_WIDTH"` + Width int `help:"Input width" default:"0" env:"GUM_FILTER_WIDTH"` Height int `help:"Input height" default:"0" env:"GUM_FILTER_HEIGHT"` Value string `help:"Initial filter value" default:"" env:"GUM_FILTER_VALUE"` Reverse bool `help:"Display from the bottom of the screen" env:"GUM_FILTER_REVERSE"` diff --git a/input/options.go b/input/options.go index 7c68889..2ef8b1a 100644 --- a/input/options.go +++ b/input/options.go @@ -16,7 +16,7 @@ type Options struct { CursorMode string `prefix:"cursor." name:"mode" help:"Cursor mode" default:"blink" enum:"blink,hide,static" env:"GUM_INPUT_CURSOR_MODE"` Value string `help:"Initial value (can also be passed via stdin)" default:""` CharLimit int `help:"Maximum value length (0 for no limit)" default:"400"` - Width int `help:"Input width (0 for terminal width)" default:"40" env:"GUM_INPUT_WIDTH"` + Width int `help:"Input width (0 for terminal width)" default:"0" env:"GUM_INPUT_WIDTH"` Password bool `help:"Mask input characters" default:"false"` ShowHelp bool `help:"Show help keybinds" default:"true" negatable:"true" env:"GUM_INPUT_SHOW_HELP"` Header string `help:"Header value" default:"" env:"GUM_INPUT_HEADER"` diff --git a/write/options.go b/write/options.go index 109c3dc..91b6596 100644 --- a/write/options.go +++ b/write/options.go @@ -4,7 +4,7 @@ import "github.com/charmbracelet/gum/style" // Options are the customization options for the textarea. type Options struct { - Width int `help:"Text area width (0 for terminal width)" default:"50" env:"GUM_WRITE_WIDTH"` + Width int `help:"Text area width (0 for terminal width)" default:"0" env:"GUM_WRITE_WIDTH"` Height int `help:"Text area height" default:"5" env:"GUM_WRITE_HEIGHT"` Header string `help:"Header value" default:"" env:"GUM_WRITE_HEADER"` Placeholder string `help:"Placeholder value" default:"Write something..." env:"GUM_WRITE_PLACEHOLDER"` From 9db5c7fbbabad605e763925eeb9e24ec836616db Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Thu, 25 Jul 2024 15:45:13 -0400 Subject: [PATCH 004/198] fix: select all keybinding (#639) * fix: select all keybinding Signed-off-by: Carlos Alexandro Becker * chore(deps): update gum Signed-off-by: Carlos Alexandro Becker --------- Signed-off-by: Carlos Alexandro Becker --- choose/command.go | 13 ++++++++----- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/choose/command.go b/choose/command.go index 89c25bd..c78b473 100644 --- a/choose/command.go +++ b/choose/command.go @@ -44,6 +44,9 @@ func (o Options) Run() error { theme.Focused.SelectedPrefix = o.SelectedItemStyle.ToLipgloss().SetString(o.SelectedPrefix) theme.Focused.UnselectedPrefix = o.ItemStyle.ToLipgloss().SetString(o.UnselectedPrefix) + keymap := huh.NewDefaultKeyMap() + keymap.MultiSelect.ToggleAll.SetKeys("a", "ctrl+a") + for _, s := range o.Selected { for i, opt := range options { if s == opt.Key || s == opt.Value { @@ -52,15 +55,15 @@ func (o Options) Run() error { } } - if o.NoLimit { - o.Limit = len(o.Options) - } - width := max(widest(o.Options)+ max(lipgloss.Width(o.SelectedPrefix)+lipgloss.Width(o.UnselectedPrefix))+ lipgloss.Width(o.Cursor)+1, lipgloss.Width(o.Header)+widthBuffer) - if o.Limit > 1 { + if o.NoLimit { + o.Limit = 0 + } + + if o.Limit > 1 || o.NoLimit { var choices []string field := huh.NewMultiSelect[string](). diff --git a/go.mod b/go.mod index f720d71..c4d8927 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/charmbracelet/bubbles v0.18.0 github.com/charmbracelet/bubbletea v0.26.7-0.20240716165615-7d708384a105 github.com/charmbracelet/glamour v0.7.0 - github.com/charmbracelet/huh v0.5.2 + github.com/charmbracelet/huh v0.5.3-0.20240725170654-1926040ccf04 github.com/charmbracelet/lipgloss v0.12.1 github.com/charmbracelet/log v0.4.0 github.com/charmbracelet/x/ansi v0.1.4 diff --git a/go.sum b/go.sum index 4c66da0..46ef293 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/charmbracelet/bubbletea v0.26.7-0.20240716165615-7d708384a105 h1:ye4X github.com/charmbracelet/bubbletea v0.26.7-0.20240716165615-7d708384a105/go.mod h1:gw7FxN8J9u7IAlwc1ab1GnbfOMGExC9iI0e1t2SHs6I= github.com/charmbracelet/glamour v0.7.0 h1:2BtKGZ4iVJCDfMF229EzbeR1QRKLWztO9dMtjmqZSng= github.com/charmbracelet/glamour v0.7.0/go.mod h1:jUMh5MeihljJPQbJ/wf4ldw2+yBP59+ctV36jASy7ps= -github.com/charmbracelet/huh v0.5.2 h1:ofeNkJ4iaFnzv46Njhx896DzLUe/j0L2QAf8znwzX4c= -github.com/charmbracelet/huh v0.5.2/go.mod h1:Sf7dY0oAn6N/e3sXJFtFX9hdQLrUdO3z7AYollG9bAM= +github.com/charmbracelet/huh v0.5.3-0.20240725170654-1926040ccf04 h1:4gl2RNDqRh0x5vGO0EPKOLXH+iEyHwq+36KNeuQ1/YI= +github.com/charmbracelet/huh v0.5.3-0.20240725170654-1926040ccf04/go.mod h1:Sf7dY0oAn6N/e3sXJFtFX9hdQLrUdO3z7AYollG9bAM= github.com/charmbracelet/lipgloss v0.12.1 h1:/gmzszl+pedQpjCOH+wFkZr/N90Snz40J/NR7A0zQcs= github.com/charmbracelet/lipgloss v0.12.1/go.mod h1:V2CiwIuhx9S1S1ZlADfOj9HmxeMAORuz5izHb0zGbB8= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= From d722a2f1b811581125911a7e1a61b4dc8e9a1ec7 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Thu, 25 Jul 2024 15:50:22 -0400 Subject: [PATCH 005/198] fix: height 0 by default (#640) --- choose/options.go | 2 +- file/options.go | 2 +- table/options.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/choose/options.go b/choose/options.go index c9f07bd..e9c393c 100644 --- a/choose/options.go +++ b/choose/options.go @@ -12,7 +12,7 @@ type Options struct { Limit int `help:"Maximum number of options to pick" default:"1" group:"Selection"` NoLimit bool `help:"Pick unlimited number of options (ignores limit)" group:"Selection"` Ordered bool `help:"Maintain the order of the selected options" env:"GUM_CHOOSE_ORDERED"` - Height int `help:"Height of the list" default:"10" env:"GUM_CHOOSE_HEIGHT"` + Height int `help:"Height of the list" default:"0" env:"GUM_CHOOSE_HEIGHT"` Cursor string `help:"Prefix to show on item that corresponds to the cursor position" default:"> " env:"GUM_CHOOSE_CURSOR"` ShowHelp bool `help:"Show help keybinds" default:"true" negatable:"true" env:"GUM_CHOOSE_SHOW_HELP"` Header string `help:"Header value" default:"Choose:" env:"GUM_CHOOSE_HEADER"` diff --git a/file/options.go b/file/options.go index 4b8e88d..5d4593d 100644 --- a/file/options.go +++ b/file/options.go @@ -17,7 +17,7 @@ type Options struct { Directory bool `help:"Allow directories selection" default:"false" env:"GUM_FILE_DIRECTORY"` ShowHelp bool `help:"Show help key binds" negatable:"" default:"true" env:"GUM_FILE_SHOW_HELP"` - Height int `help:"Maximum number of files to display" default:"10" env:"GUM_FILE_HEIGHT"` + Height int `help:"Maximum number of files to display" default:"0" env:"GUM_FILE_HEIGHT"` CursorStyle style.Styles `embed:"" prefix:"cursor." help:"The cursor style" set:"defaultForeground=212" envprefix:"GUM_FILE_CURSOR_"` SymlinkStyle style.Styles `embed:"" prefix:"symlink." help:"The style to use for symlinks" set:"defaultForeground=36" envprefix:"GUM_FILE_SYMLINK_"` DirectoryStyle style.Styles `embed:"" prefix:"directory." help:"The style to use for directories" set:"defaultForeground=99" envprefix:"GUM_FILE_DIRECTORY_"` diff --git a/table/options.go b/table/options.go index b70578c..a7a3f29 100644 --- a/table/options.go +++ b/table/options.go @@ -7,7 +7,7 @@ type Options struct { Separator string `short:"s" help:"Row separator" default:","` Columns []string `short:"c" help:"Column names"` Widths []int `short:"w" help:"Column widths"` - Height int `help:"Table height" default:"10"` + Height int `help:"Table height" default:"0"` Print bool `short:"p" help:"static print" default:"false"` File string `short:"f" help:"file path" default:""` Border string `short:"b" help:"border style" default:"rounded" enum:"rounded,thick,normal,hidden,double,none"` From 7e56d57478d14e2a5378d57f0c5f45e74bbadf7d Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Thu, 25 Jul 2024 15:58:29 -0400 Subject: [PATCH 006/198] docs: update install instructions closes #474 --- README.md | 81 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 120ea16..135cb9c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -Gum -=== +# Gum

Gum Image @@ -22,10 +21,12 @@ The above example is running from a single shell script ([source](./examples/dem Gum provides highly configurable, ready-to-use utilities to help you write useful shell scripts and dotfiles aliases with just a few lines of code. -Let's build a simple script to help you write [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) +Let's build a simple script to help you write +[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) for your dotfiles. Ask for the commit type with gum choose: + ```bash gum choose "fix" "feat" "docs" "style" "refactor" "test" "chore" "revert" ``` @@ -34,17 +35,20 @@ gum choose "fix" "feat" "docs" "style" "refactor" "test" "chore" "revert" > This command itself will print to stdout which is not all that useful. To make use of the command later on you can save the stdout to a `$VARIABLE` or `file.txt`. Prompt for the scope of these changes: + ```bash gum input --placeholder "scope" ``` Prompt for the summary and description of changes: + ```bash gum input --value "$TYPE$SCOPE: " --placeholder "Summary of this change" gum write --placeholder "Details of this change" ``` Confirm before committing: + ```bash gum confirm "Commit changes?" && git commit -m "$SUMMARY" -m "$DESCRIPTION" ``` @@ -84,10 +88,11 @@ curl -fsSL https://repo.charm.sh/apt/gpg.key | sudo gpg --dearmor -o /etc/apt/ke echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | sudo tee /etc/apt/sources.list.d/charm.list sudo apt update && sudo apt install gum ``` +

-Fedora/RHEL +Fedora/RHEL/OpenSuse ```bash echo '[charm] @@ -96,14 +101,22 @@ baseurl=https://repo.charm.sh/yum/ enabled=1 gpgcheck=1 gpgkey=https://repo.charm.sh/yum/gpg.key' | sudo tee /etc/yum.repos.d/charm.repo +sudo rpm --import https://repo.charm.sh/yum/gpg.key + +# yum sudo yum install gum + +# zypper +sudo zypper refresh +sudo zypper install gum ``` +
Or download it: -* [Packages][releases] are available in Debian, RPM, and Alpine formats -* [Binaries][releases] are available for Linux, macOS, Windows, FreeBSD, OpenBSD, and NetBSD +- [Packages][releases] are available in Debian, RPM, and Alpine formats +- [Binaries][releases] are available for Linux, macOS, Windows, FreeBSD, OpenBSD, and NetBSD Or just install it with `go`: @@ -115,20 +128,19 @@ go install github.com/charmbracelet/gum@latest ## Commands - * [`choose`](#choose): Choose an option from a list of choices - * [`confirm`](#confirm): Ask a user to confirm an action - * [`file`](#file): Pick a file from a folder - * [`filter`](#filter): Filter items from a list - * [`format`](#format): Format a string using a template - * [`input`](#input): Prompt for some input - * [`join`](#join): Join text vertically or horizontally - * [`pager`](#pager): Scroll through a file - * [`spin`](#spin): Display spinner while running a command - * [`style`](#style): Apply coloring, borders, spacing to text - * [`table`](#table): Render a table of data - * [`write`](#write): Prompt for long-form text - * [`log`](#log): Log messages to output - +- [`choose`](#choose): Choose an option from a list of choices +- [`confirm`](#confirm): Ask a user to confirm an action +- [`file`](#file): Pick a file from a folder +- [`filter`](#filter): Filter items from a list +- [`format`](#format): Format a string using a template +- [`input`](#input): Prompt for some input +- [`join`](#join): Join text vertically or horizontally +- [`pager`](#pager): Scroll through a file +- [`spin`](#spin): Display spinner while running a command +- [`style`](#style): Apply coloring, borders, spacing to text +- [`table`](#table): Render a table of data +- [`write`](#write): Prompt for long-form text +- [`log`](#log): Log messages to output ## Customization @@ -136,6 +148,7 @@ You can customize `gum` options and styles with `--flags` and `$ENVIRONMENT_VARI See `gum --help` for a full view of each command's customization and configuration options. Customize with `--flags`: + ```bash gum input --cursor.foreground "#FF0" \ @@ -369,63 +382,63 @@ How to use `gum` in your daily workflows: See the [examples](./examples/) directory for more real world use cases. -* Write a commit message: +- Write a commit message: ```bash git commit -m "$(gum input --width 50 --placeholder "Summary of changes")" \ -m "$(gum write --width 80 --placeholder "Details of changes")" ``` -* Open files in your `$EDITOR` +- Open files in your `$EDITOR` ```bash $EDITOR $(gum filter) ``` -* Connect to a `tmux` session +- Connect to a `tmux` session ```bash SESSION=$(tmux list-sessions -F \#S | gum filter --placeholder "Pick session...") tmux switch-client -t $SESSION || tmux attach -t $SESSION ``` -* Pick a commit hash from `git` history +- Pick a commit hash from `git` history ```bash git log --oneline | gum filter | cut -d' ' -f1 # | copy ``` -* Simple [`skate`](https://github.com/charmbracelet/skate) password selector. +- Simple [`skate`](https://github.com/charmbracelet/skate) password selector. ``` skate list -k | gum filter | xargs skate get ``` -* Uninstall packages +- Uninstall packages ```bash brew list | gum choose --no-limit | xargs brew uninstall ``` -* Clean up `git` branches +- Clean up `git` branches ```bash git branch | cut -c 3- | gum choose --no-limit | xargs git branch -D ``` -* Checkout GitHub pull requests with [`gh`](https://cli.github.com/) +- Checkout GitHub pull requests with [`gh`](https://cli.github.com/) ```bash gh pr list | cut -f1,2 | gum choose | cut -f1 | xargs gh pr checkout ``` -* Copy command from shell history +- Copy command from shell history ```bash gum filter < $HISTFILE --height 20 ``` -* `sudo` replacement +- `sudo` replacement ```bash alias please="gum input --password | sudo -nS" @@ -435,15 +448,15 @@ alias please="gum input --password | sudo -nS" We’d love to hear your thoughts on this project. Feel free to drop us a note! -* [Twitter](https://twitter.com/charmcli) -* [The Fediverse](https://mastodon.social/@charmcli) -* [Discord](https://charm.sh/chat) +- [Twitter](https://twitter.com/charmcli) +- [The Fediverse](https://mastodon.social/@charmcli) +- [Discord](https://charm.sh/chat) ## License [MIT](https://github.com/charmbracelet/gum/raw/main/LICENSE) -*** +--- Part of [Charm](https://charm.sh). From 96448e08e575c5ccd3bdc7b30fc09c67775e2847 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Thu, 25 Jul 2024 16:56:03 -0400 Subject: [PATCH 007/198] fix: show background style help (#641) Signed-off-by: Carlos Alexandro Becker --- style/options.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/style/options.go b/style/options.go index 0b250c2..906b551 100644 --- a/style/options.go +++ b/style/options.go @@ -15,7 +15,7 @@ type Options struct { type Styles struct { // Colors Foreground string `help:"Foreground Color" default:"${defaultForeground}" group:"Style Flags" env:"FOREGROUND"` - Background string `help:"Background Color" default:"${defaultBackground}" group:"Style Flags" env:"BACKGROUND" hidden:"true"` + Background string `help:"Background Color" default:"${defaultBackground}" group:"Style Flags" env:"BACKGROUND"` // Border Border string `help:"Border Style" enum:"none,hidden,normal,rounded,thick,double" default:"${defaultBorder}" group:"Style Flags" env:"BORDER" hidden:"true"` From f55c3145580caf4c094f5b04e01d08b0ca155127 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 14 Aug 2024 14:01:26 -0300 Subject: [PATCH 008/198] fix(deps): update huh --- choose/command.go | 3 --- go.mod | 16 ++++++++-------- go.sum | 28 ++++++++++++---------------- 3 files changed, 20 insertions(+), 27 deletions(-) diff --git a/choose/command.go b/choose/command.go index c78b473..38937c2 100644 --- a/choose/command.go +++ b/choose/command.go @@ -44,9 +44,6 @@ func (o Options) Run() error { theme.Focused.SelectedPrefix = o.SelectedItemStyle.ToLipgloss().SetString(o.SelectedPrefix) theme.Focused.UnselectedPrefix = o.ItemStyle.ToLipgloss().SetString(o.UnselectedPrefix) - keymap := huh.NewDefaultKeyMap() - keymap.MultiSelect.ToggleAll.SetKeys("a", "ctrl+a") - for _, s := range o.Selected { for i, opt := range options { if s == opt.Key || s == opt.Value { diff --git a/go.mod b/go.mod index c4d8927..842b52e 100644 --- a/go.mod +++ b/go.mod @@ -5,13 +5,13 @@ go 1.21 require ( github.com/alecthomas/kong v0.9.0 github.com/alecthomas/mango-kong v0.1.0 - github.com/charmbracelet/bubbles v0.18.0 - github.com/charmbracelet/bubbletea v0.26.7-0.20240716165615-7d708384a105 + github.com/charmbracelet/bubbles v0.18.1-0.20240813162745-2de0504eb509 + github.com/charmbracelet/bubbletea v0.26.7-0.20240813155527-7782a600eb35 github.com/charmbracelet/glamour v0.7.0 - github.com/charmbracelet/huh v0.5.3-0.20240725170654-1926040ccf04 + github.com/charmbracelet/huh v0.5.3-0.20240813141447-57c1e0379197 github.com/charmbracelet/lipgloss v0.12.1 github.com/charmbracelet/log v0.4.0 - github.com/charmbracelet/x/ansi v0.1.4 + github.com/charmbracelet/x/ansi v0.1.5-0.20240812190614-74518029592c github.com/charmbracelet/x/term v0.1.1 github.com/muesli/reflow v0.3.0 github.com/muesli/roff v0.1.0 @@ -35,7 +35,6 @@ require ( github.com/gorilla/css v1.0.1 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-localereader v0.0.1 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect github.com/microcosm-cc/bluemonday v1.0.26 // indirect github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect @@ -49,7 +48,8 @@ require ( github.com/yuin/goldmark-emoji v1.0.2 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/net v0.26.0 // indirect - golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.24.0 // indirect ) + +replace github.com/charmbracelet/huh => ../huh diff --git a/go.sum b/go.sum index 46ef293..78b6bed 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= +github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= github.com/alecthomas/assert/v2 v2.7.0 h1:QtqSACNS3tF7oasA8CU6A6sXZSBDqnm7RfpLl9bZqbE= github.com/alecthomas/assert/v2 v2.7.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E= @@ -16,20 +18,18 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/catppuccin/go v0.2.0 h1:ktBeIrIP42b/8FGiScP9sgrWOss3lw0Z5SktRoithGA= github.com/catppuccin/go v0.2.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc= -github.com/charmbracelet/bubbles v0.18.0 h1:PYv1A036luoBGroX6VWjQIE9Syf2Wby2oOl/39KLfy0= -github.com/charmbracelet/bubbles v0.18.0/go.mod h1:08qhZhtIwzgrtBjAcJnij1t1H0ZRjwHyGsy6AL11PSw= -github.com/charmbracelet/bubbletea v0.26.7-0.20240716165615-7d708384a105 h1:ye4X1GMrzY6ebvZeUB9bgyxreb5xxa5o9Kd/Y/auxFs= -github.com/charmbracelet/bubbletea v0.26.7-0.20240716165615-7d708384a105/go.mod h1:gw7FxN8J9u7IAlwc1ab1GnbfOMGExC9iI0e1t2SHs6I= +github.com/charmbracelet/bubbles v0.18.1-0.20240813162745-2de0504eb509 h1:z0XlwqGRw9xaY59ay6ees2i0DYtd4N+nsKs9PqEYg6I= +github.com/charmbracelet/bubbles v0.18.1-0.20240813162745-2de0504eb509/go.mod h1:WjBQiVnuMhc21a7y3LLEmCYHJKuoaNg5w/s51L9Z+OA= +github.com/charmbracelet/bubbletea v0.26.7-0.20240813155527-7782a600eb35 h1:Uswu4lD3QvV+qfqRa/I8go9qD8nhfI35U0s5mUH1D7U= +github.com/charmbracelet/bubbletea v0.26.7-0.20240813155527-7782a600eb35/go.mod h1:PSJxIF5dhW9uzAl2y5GOtozGn+8kB3xK2IRNabBbey4= github.com/charmbracelet/glamour v0.7.0 h1:2BtKGZ4iVJCDfMF229EzbeR1QRKLWztO9dMtjmqZSng= github.com/charmbracelet/glamour v0.7.0/go.mod h1:jUMh5MeihljJPQbJ/wf4ldw2+yBP59+ctV36jASy7ps= -github.com/charmbracelet/huh v0.5.3-0.20240725170654-1926040ccf04 h1:4gl2RNDqRh0x5vGO0EPKOLXH+iEyHwq+36KNeuQ1/YI= -github.com/charmbracelet/huh v0.5.3-0.20240725170654-1926040ccf04/go.mod h1:Sf7dY0oAn6N/e3sXJFtFX9hdQLrUdO3z7AYollG9bAM= github.com/charmbracelet/lipgloss v0.12.1 h1:/gmzszl+pedQpjCOH+wFkZr/N90Snz40J/NR7A0zQcs= github.com/charmbracelet/lipgloss v0.12.1/go.mod h1:V2CiwIuhx9S1S1ZlADfOj9HmxeMAORuz5izHb0zGbB8= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= -github.com/charmbracelet/x/ansi v0.1.4 h1:IEU3D6+dWwPSgZ6HBH+v6oUuZ/nVawMiWj5831KfiLM= -github.com/charmbracelet/x/ansi v0.1.4/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= +github.com/charmbracelet/x/ansi v0.1.5-0.20240812190614-74518029592c h1:AYrQmylspZQMvm92p4TEOIXq45F5eWgnCnEltRt0SIQ= +github.com/charmbracelet/x/ansi v0.1.5-0.20240812190614-74518029592c/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 h1:qko3AQ4gK1MTS/de7F5hPGx6/k1u0w4TeYmBFwzYVP4= github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0/go.mod h1:pBhA0ybfXv6hDjQUZ7hk1lVxBiUbupdw5R31yPUViVQ= github.com/charmbracelet/x/exp/term v0.0.0-20240524151031-ff83003bf67a h1:k/s6UoOSVynWiw7PlclyGO2VdVs5ZLbMIHiGp4shFZE= @@ -60,8 +60,6 @@ github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69 github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4= -github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= @@ -105,13 +103,11 @@ golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0J golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From e095a9142b740b08b2252df7c96e2c9571518751 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 19 Aug 2024 11:59:01 -0300 Subject: [PATCH 009/198] fix(input): wrong height when using borders in the header closes #582 Signed-off-by: Carlos Alexandro Becker --- go.mod | 12 +++++++----- go.sum | 22 ++++++++++++---------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index 842b52e..c1dbcf5 100644 --- a/go.mod +++ b/go.mod @@ -5,17 +5,17 @@ go 1.21 require ( github.com/alecthomas/kong v0.9.0 github.com/alecthomas/mango-kong v0.1.0 - github.com/charmbracelet/bubbles v0.18.1-0.20240813162745-2de0504eb509 - github.com/charmbracelet/bubbletea v0.26.7-0.20240813155527-7782a600eb35 + github.com/charmbracelet/bubbles v0.18.1-0.20240815190156-5428d6ddecae + github.com/charmbracelet/bubbletea v0.27.0 github.com/charmbracelet/glamour v0.7.0 - github.com/charmbracelet/huh v0.5.3-0.20240813141447-57c1e0379197 - github.com/charmbracelet/lipgloss v0.12.1 + github.com/charmbracelet/huh v0.5.3-0.20240819144924-03b9fb7b7e9b + github.com/charmbracelet/lipgloss v0.12.2-0.20240807180434-0618c73743d9 github.com/charmbracelet/log v0.4.0 github.com/charmbracelet/x/ansi v0.1.5-0.20240812190614-74518029592c github.com/charmbracelet/x/term v0.1.1 github.com/muesli/reflow v0.3.0 github.com/muesli/roff v0.1.0 - github.com/muesli/termenv v0.15.2 + github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a github.com/sahilm/fuzzy v0.1.1 ) @@ -35,6 +35,7 @@ require ( github.com/gorilla/css v1.0.1 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mattn/go-localereader v0.0.1 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect github.com/microcosm-cc/bluemonday v1.0.26 // indirect github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect @@ -50,6 +51,7 @@ require ( golang.org/x/net v0.26.0 // indirect golang.org/x/sync v0.8.0 // indirect golang.org/x/sys v0.24.0 // indirect + golang.org/x/text v0.16.0 // indirect ) replace github.com/charmbracelet/huh => ../huh diff --git a/go.sum b/go.sum index 78b6bed..3bf46c6 100644 --- a/go.sum +++ b/go.sum @@ -18,22 +18,20 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/catppuccin/go v0.2.0 h1:ktBeIrIP42b/8FGiScP9sgrWOss3lw0Z5SktRoithGA= github.com/catppuccin/go v0.2.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc= -github.com/charmbracelet/bubbles v0.18.1-0.20240813162745-2de0504eb509 h1:z0XlwqGRw9xaY59ay6ees2i0DYtd4N+nsKs9PqEYg6I= -github.com/charmbracelet/bubbles v0.18.1-0.20240813162745-2de0504eb509/go.mod h1:WjBQiVnuMhc21a7y3LLEmCYHJKuoaNg5w/s51L9Z+OA= -github.com/charmbracelet/bubbletea v0.26.7-0.20240813155527-7782a600eb35 h1:Uswu4lD3QvV+qfqRa/I8go9qD8nhfI35U0s5mUH1D7U= -github.com/charmbracelet/bubbletea v0.26.7-0.20240813155527-7782a600eb35/go.mod h1:PSJxIF5dhW9uzAl2y5GOtozGn+8kB3xK2IRNabBbey4= +github.com/charmbracelet/bubbles v0.18.1-0.20240815190156-5428d6ddecae h1:PeBjEy2piL/M5ud8OxbwPbZL1XUTsP772uKwdzW0REo= +github.com/charmbracelet/bubbles v0.18.1-0.20240815190156-5428d6ddecae/go.mod h1:ShdVGYAMXQWsa2HXeoGOmpYwJGOqjkYB7aVzUsp90yA= +github.com/charmbracelet/bubbletea v0.27.0 h1:Mznj+vvYuYagD9Pn2mY7fuelGvP0HAXtZYGgRBCbHvU= +github.com/charmbracelet/bubbletea v0.27.0/go.mod h1:5MdP9XH6MbQkgGhnlxUqCNmBXf9I74KRQ8HIidRxV1Y= github.com/charmbracelet/glamour v0.7.0 h1:2BtKGZ4iVJCDfMF229EzbeR1QRKLWztO9dMtjmqZSng= github.com/charmbracelet/glamour v0.7.0/go.mod h1:jUMh5MeihljJPQbJ/wf4ldw2+yBP59+ctV36jASy7ps= -github.com/charmbracelet/lipgloss v0.12.1 h1:/gmzszl+pedQpjCOH+wFkZr/N90Snz40J/NR7A0zQcs= -github.com/charmbracelet/lipgloss v0.12.1/go.mod h1:V2CiwIuhx9S1S1ZlADfOj9HmxeMAORuz5izHb0zGbB8= +github.com/charmbracelet/lipgloss v0.12.2-0.20240807180434-0618c73743d9 h1:gAepUCzOGTqCn9E/TqBeh29kq6I295ax9HxT0dUJSoo= +github.com/charmbracelet/lipgloss v0.12.2-0.20240807180434-0618c73743d9/go.mod h1:lVwxBOJ0KkZflL9y+DObgGY8V90IZUJ1e6jjZ+PBcnE= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= github.com/charmbracelet/x/ansi v0.1.5-0.20240812190614-74518029592c h1:AYrQmylspZQMvm92p4TEOIXq45F5eWgnCnEltRt0SIQ= github.com/charmbracelet/x/ansi v0.1.5-0.20240812190614-74518029592c/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 h1:qko3AQ4gK1MTS/de7F5hPGx6/k1u0w4TeYmBFwzYVP4= github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0/go.mod h1:pBhA0ybfXv6hDjQUZ7hk1lVxBiUbupdw5R31yPUViVQ= -github.com/charmbracelet/x/exp/term v0.0.0-20240524151031-ff83003bf67a h1:k/s6UoOSVynWiw7PlclyGO2VdVs5ZLbMIHiGp4shFZE= -github.com/charmbracelet/x/exp/term v0.0.0-20240524151031-ff83003bf67a/go.mod h1:YBotIGhfoWhHDlnUpJMkjebGV2pdGRCn1Y4/Nk/vVcU= github.com/charmbracelet/x/input v0.1.3 h1:oy4TMhyGQsYs/WWJwu1ELUMFnjiUAXwtDf048fHbCkg= github.com/charmbracelet/x/input v0.1.3/go.mod h1:1gaCOyw1KI9e2j00j/BBZ4ErzRZqa05w0Ghn83yIhKU= github.com/charmbracelet/x/term v0.1.1 h1:3cosVAiPOig+EV4X9U+3LDgtwwAoEzJjNdwbXDjF6yI= @@ -60,6 +58,8 @@ github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69 github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4= +github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= @@ -78,8 +78,8 @@ github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s= github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8= github.com/muesli/roff v0.1.0 h1:YD0lalCotmYuF5HhZliKWlIx7IEhiXeSfq7hNjFqGF8= github.com/muesli/roff v0.1.0/go.mod h1:pjAHQM9hdUUwm/krAfrLGgJkXJ+YuhtsfZ42kieB2Ig= -github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo= -github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8= +github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a h1:2MaM6YC3mGu54x+RKAA6JiFFHlHDY1UbkxqppT7wYOg= +github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a/go.mod h1:hxSnBBYLK21Vtq/PHd0S2FYCxBXzBua8ov5s1RobyRQ= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -109,5 +109,7 @@ golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 19a93b08b97e58ba22b1276da2fcfc8f4a82c7f1 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 19 Aug 2024 12:00:02 -0300 Subject: [PATCH 010/198] refactor(input): simplify echoMode Signed-off-by: Carlos Alexandro Becker --- input/command.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/input/command.go b/input/command.go index 57fc8a8..b35ce20 100644 --- a/input/command.go +++ b/input/command.go @@ -2,7 +2,6 @@ package input import ( "fmt" - "os" "github.com/charmbracelet/bubbles/key" @@ -34,12 +33,9 @@ func (o Options) Run() error { keymap := huh.NewDefaultKeyMap() keymap.Quit = key.NewBinding(key.WithKeys("ctrl+c", "esc")) - var echoMode huh.EchoMode - + echoMode := huh.EchoModeNormal if o.Password { echoMode = huh.EchoModePassword - } else { - echoMode = huh.EchoModeNormal } err := huh.NewForm( @@ -60,7 +56,6 @@ func (o Options) Run() error { WithShowHelp(o.ShowHelp). WithProgramOptions(tea.WithOutput(os.Stderr)). Run() - if err != nil { return err } From c9a4e4fa7b25d63588c91581b3ee8a205562e797 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 19 Aug 2024 14:55:27 -0300 Subject: [PATCH 011/198] chore(deps): remove replace Signed-off-by: Carlos Alexandro Becker --- go.mod | 2 -- go.sum | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index c1dbcf5..9cd0f2b 100644 --- a/go.mod +++ b/go.mod @@ -53,5 +53,3 @@ require ( golang.org/x/sys v0.24.0 // indirect golang.org/x/text v0.16.0 // indirect ) - -replace github.com/charmbracelet/huh => ../huh diff --git a/go.sum b/go.sum index 3bf46c6..661a72f 100644 --- a/go.sum +++ b/go.sum @@ -24,6 +24,8 @@ github.com/charmbracelet/bubbletea v0.27.0 h1:Mznj+vvYuYagD9Pn2mY7fuelGvP0HAXtZY github.com/charmbracelet/bubbletea v0.27.0/go.mod h1:5MdP9XH6MbQkgGhnlxUqCNmBXf9I74KRQ8HIidRxV1Y= github.com/charmbracelet/glamour v0.7.0 h1:2BtKGZ4iVJCDfMF229EzbeR1QRKLWztO9dMtjmqZSng= github.com/charmbracelet/glamour v0.7.0/go.mod h1:jUMh5MeihljJPQbJ/wf4ldw2+yBP59+ctV36jASy7ps= +github.com/charmbracelet/huh v0.5.3-0.20240819144924-03b9fb7b7e9b h1:iHGpWtc+F61rFGlTd0ug+EnWIF02m7Rs0kTCbkoFPIo= +github.com/charmbracelet/huh v0.5.3-0.20240819144924-03b9fb7b7e9b/go.mod h1:AXVw0P9wv9BuniLHtdJvuzBbcfxufAJ3sgweykxEp+4= github.com/charmbracelet/lipgloss v0.12.2-0.20240807180434-0618c73743d9 h1:gAepUCzOGTqCn9E/TqBeh29kq6I295ax9HxT0dUJSoo= github.com/charmbracelet/lipgloss v0.12.2-0.20240807180434-0618c73743d9/go.mod h1:lVwxBOJ0KkZflL9y+DObgGY8V90IZUJ1e6jjZ+PBcnE= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= From 1a91d335fa67b4b90793231fb2b55c579cbfdaaa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 15:00:32 -0300 Subject: [PATCH 012/198] feat(deps): bump github.com/charmbracelet/glamour from 0.7.0 to 0.8.0 (#646) Bumps [github.com/charmbracelet/glamour](https://github.com/charmbracelet/glamour) from 0.7.0 to 0.8.0. - [Release notes](https://github.com/charmbracelet/glamour/releases) - [Commits](https://github.com/charmbracelet/glamour/compare/v0.7.0...v0.8.0) --- updated-dependencies: - dependency-name: github.com/charmbracelet/glamour dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 12 ++++++------ go.sum | 31 +++++++++++++++++-------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/go.mod b/go.mod index 9cd0f2b..4723b7c 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.18.1-0.20240815190156-5428d6ddecae github.com/charmbracelet/bubbletea v0.27.0 - github.com/charmbracelet/glamour v0.7.0 + github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/huh v0.5.3-0.20240819144924-03b9fb7b7e9b github.com/charmbracelet/lipgloss v0.12.2-0.20240807180434-0618c73743d9 github.com/charmbracelet/log v0.4.0 @@ -37,19 +37,19 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-localereader v0.0.1 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect - github.com/microcosm-cc/bluemonday v1.0.26 // indirect + github.com/microcosm-cc/bluemonday v1.0.27 // indirect github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect github.com/muesli/cancelreader v0.2.2 // indirect github.com/muesli/mango v0.2.0 // indirect - github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect - github.com/yuin/goldmark v1.7.2 // indirect - github.com/yuin/goldmark-emoji v1.0.2 // indirect + github.com/yuin/goldmark v1.7.4 // indirect + github.com/yuin/goldmark-emoji v1.0.3 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect - golang.org/x/net v0.26.0 // indirect + golang.org/x/net v0.27.0 // indirect golang.org/x/sync v0.8.0 // indirect golang.org/x/sys v0.24.0 // indirect + golang.org/x/term v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect ) diff --git a/go.sum b/go.sum index 661a72f..39e1e74 100644 --- a/go.sum +++ b/go.sum @@ -14,6 +14,8 @@ github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= +github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8= +github.com/aymanbagabas/go-udiff v0.2.0/go.mod h1:RE4Ex0qsGkTAJoQdQQCA0uG+nAzJO/pI/QwceO5fgrA= github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/catppuccin/go v0.2.0 h1:ktBeIrIP42b/8FGiScP9sgrWOss3lw0Z5SktRoithGA= @@ -22,8 +24,8 @@ github.com/charmbracelet/bubbles v0.18.1-0.20240815190156-5428d6ddecae h1:PeBjEy github.com/charmbracelet/bubbles v0.18.1-0.20240815190156-5428d6ddecae/go.mod h1:ShdVGYAMXQWsa2HXeoGOmpYwJGOqjkYB7aVzUsp90yA= github.com/charmbracelet/bubbletea v0.27.0 h1:Mznj+vvYuYagD9Pn2mY7fuelGvP0HAXtZYGgRBCbHvU= github.com/charmbracelet/bubbletea v0.27.0/go.mod h1:5MdP9XH6MbQkgGhnlxUqCNmBXf9I74KRQ8HIidRxV1Y= -github.com/charmbracelet/glamour v0.7.0 h1:2BtKGZ4iVJCDfMF229EzbeR1QRKLWztO9dMtjmqZSng= -github.com/charmbracelet/glamour v0.7.0/go.mod h1:jUMh5MeihljJPQbJ/wf4ldw2+yBP59+ctV36jASy7ps= +github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= +github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= github.com/charmbracelet/huh v0.5.3-0.20240819144924-03b9fb7b7e9b h1:iHGpWtc+F61rFGlTd0ug+EnWIF02m7Rs0kTCbkoFPIo= github.com/charmbracelet/huh v0.5.3-0.20240819144924-03b9fb7b7e9b/go.mod h1:AXVw0P9wv9BuniLHtdJvuzBbcfxufAJ3sgweykxEp+4= github.com/charmbracelet/lipgloss v0.12.2-0.20240807180434-0618c73743d9 h1:gAepUCzOGTqCn9E/TqBeh29kq6I295ax9HxT0dUJSoo= @@ -32,6 +34,8 @@ github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8 github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= github.com/charmbracelet/x/ansi v0.1.5-0.20240812190614-74518029592c h1:AYrQmylspZQMvm92p4TEOIXq45F5eWgnCnEltRt0SIQ= github.com/charmbracelet/x/ansi v0.1.5-0.20240812190614-74518029592c/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= +github.com/charmbracelet/x/exp/golden v0.0.0-20240715153702-9ba8adf781c4 h1:6KzMkQeAF56rggw2NZu1L+TH7j9+DM1/2Kmh7KUxg1I= +github.com/charmbracelet/x/exp/golden v0.0.0-20240715153702-9ba8adf781c4/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 h1:qko3AQ4gK1MTS/de7F5hPGx6/k1u0w4TeYmBFwzYVP4= github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0/go.mod h1:pBhA0ybfXv6hDjQUZ7hk1lVxBiUbupdw5R31yPUViVQ= github.com/charmbracelet/x/input v0.1.3 h1:oy4TMhyGQsYs/WWJwu1ELUMFnjiUAXwtDf048fHbCkg= @@ -62,12 +66,11 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4= github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88= -github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/microcosm-cc/bluemonday v1.0.26 h1:xbqSvqzQMeEHCqMi64VAs4d8uy6Mequs3rQ0k/Khz58= -github.com/microcosm-cc/bluemonday v1.0.26/go.mod h1:JyzOCs9gkyQyjs+6h10UEVSe02CGwkhd72Xdqh78TWs= +github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk= +github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA= github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4= github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE= github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI= @@ -82,8 +85,6 @@ github.com/muesli/roff v0.1.0 h1:YD0lalCotmYuF5HhZliKWlIx7IEhiXeSfq7hNjFqGF8= github.com/muesli/roff v0.1.0/go.mod h1:pjAHQM9hdUUwm/krAfrLGgJkXJ+YuhtsfZ42kieB2Ig= github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a h1:2MaM6YC3mGu54x+RKAA6JiFFHlHDY1UbkxqppT7wYOg= github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a/go.mod h1:hxSnBBYLK21Vtq/PHd0S2FYCxBXzBua8ov5s1RobyRQ= -github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= -github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= @@ -96,21 +97,23 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= -github.com/yuin/goldmark v1.3.7/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.7.2 h1:NjGd7lO7zrUn/A7eKwn5PEOt4ONYGqpxSEeZuduvgxc= -github.com/yuin/goldmark v1.7.2/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= -github.com/yuin/goldmark-emoji v1.0.2 h1:c/RgTShNgHTtc6xdz2KKI74jJr6rWi7FPgnP9GAsO5s= -github.com/yuin/goldmark-emoji v1.0.2/go.mod h1:RhP/RWpexdp+KHs7ghKnifRoIs/Bq4nDS7tRbCkOwKY= +github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= +github.com/yuin/goldmark v1.7.4 h1:BDXOHExt+A7gwPCJgPIIq7ENvceR7we7rOS9TNoLZeg= +github.com/yuin/goldmark v1.7.4/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= +github.com/yuin/goldmark-emoji v1.0.3 h1:aLRkLHOuBR2czCY4R8olwMjID+tENfhyFDMCRhbIQY4= +github.com/yuin/goldmark-emoji v1.0.3/go.mod h1:tTkZEbwu5wkPmgTcitqddVxY9osFZiavD+r4AzQrh1U= golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY= golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= -golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= +golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= +golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= From dd5aa97c4a4592a719e02e67f2c6b5d0321b7f86 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Aug 2024 15:39:44 -0300 Subject: [PATCH 013/198] feat(deps): bump github.com/charmbracelet/bubbles (#654) Bumps [github.com/charmbracelet/bubbles](https://github.com/charmbracelet/bubbles) from 0.18.1-0.20240815190156-5428d6ddecae to 0.19.0. - [Release notes](https://github.com/charmbracelet/bubbles/releases) - [Changelog](https://github.com/charmbracelet/bubbles/blob/master/.goreleaser.yml) - [Commits](https://github.com/charmbracelet/bubbles/commits/v0.19.0) --- updated-dependencies: - dependency-name: github.com/charmbracelet/bubbles dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 4723b7c..866ffea 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.21 require ( github.com/alecthomas/kong v0.9.0 github.com/alecthomas/mango-kong v0.1.0 - github.com/charmbracelet/bubbles v0.18.1-0.20240815190156-5428d6ddecae + github.com/charmbracelet/bubbles v0.19.0 github.com/charmbracelet/bubbletea v0.27.0 github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/huh v0.5.3-0.20240819144924-03b9fb7b7e9b diff --git a/go.sum b/go.sum index 39e1e74..b66bafe 100644 --- a/go.sum +++ b/go.sum @@ -20,8 +20,8 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/catppuccin/go v0.2.0 h1:ktBeIrIP42b/8FGiScP9sgrWOss3lw0Z5SktRoithGA= github.com/catppuccin/go v0.2.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc= -github.com/charmbracelet/bubbles v0.18.1-0.20240815190156-5428d6ddecae h1:PeBjEy2piL/M5ud8OxbwPbZL1XUTsP772uKwdzW0REo= -github.com/charmbracelet/bubbles v0.18.1-0.20240815190156-5428d6ddecae/go.mod h1:ShdVGYAMXQWsa2HXeoGOmpYwJGOqjkYB7aVzUsp90yA= +github.com/charmbracelet/bubbles v0.19.0 h1:gKZkKXPP6GlDk6EcfujDK19PCQqRjaJZQ7QRERx1UF0= +github.com/charmbracelet/bubbles v0.19.0/go.mod h1:WILteEqZ+krG5c3ntGEMeG99nCupcuIk7V0/zOP0tOA= github.com/charmbracelet/bubbletea v0.27.0 h1:Mznj+vvYuYagD9Pn2mY7fuelGvP0HAXtZYGgRBCbHvU= github.com/charmbracelet/bubbletea v0.27.0/go.mod h1:5MdP9XH6MbQkgGhnlxUqCNmBXf9I74KRQ8HIidRxV1Y= github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= @@ -34,8 +34,8 @@ github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8 github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= github.com/charmbracelet/x/ansi v0.1.5-0.20240812190614-74518029592c h1:AYrQmylspZQMvm92p4TEOIXq45F5eWgnCnEltRt0SIQ= github.com/charmbracelet/x/ansi v0.1.5-0.20240812190614-74518029592c/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= -github.com/charmbracelet/x/exp/golden v0.0.0-20240715153702-9ba8adf781c4 h1:6KzMkQeAF56rggw2NZu1L+TH7j9+DM1/2Kmh7KUxg1I= -github.com/charmbracelet/x/exp/golden v0.0.0-20240715153702-9ba8adf781c4/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= +github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q= +github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 h1:qko3AQ4gK1MTS/de7F5hPGx6/k1u0w4TeYmBFwzYVP4= github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0/go.mod h1:pBhA0ybfXv6hDjQUZ7hk1lVxBiUbupdw5R31yPUViVQ= github.com/charmbracelet/x/input v0.1.3 h1:oy4TMhyGQsYs/WWJwu1ELUMFnjiUAXwtDf048fHbCkg= From 2ee90c889394e3e3a8e022f05097b0f643bf7c58 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Aug 2024 18:48:10 +0000 Subject: [PATCH 014/198] feat(deps): bump github.com/charmbracelet/lipgloss (#655) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 866ffea..77728ee 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/charmbracelet/bubbletea v0.27.0 github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/huh v0.5.3-0.20240819144924-03b9fb7b7e9b - github.com/charmbracelet/lipgloss v0.12.2-0.20240807180434-0618c73743d9 + github.com/charmbracelet/lipgloss v0.13.0 github.com/charmbracelet/log v0.4.0 github.com/charmbracelet/x/ansi v0.1.5-0.20240812190614-74518029592c github.com/charmbracelet/x/term v0.1.1 diff --git a/go.sum b/go.sum index b66bafe..0afce21 100644 --- a/go.sum +++ b/go.sum @@ -28,8 +28,8 @@ github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= github.com/charmbracelet/huh v0.5.3-0.20240819144924-03b9fb7b7e9b h1:iHGpWtc+F61rFGlTd0ug+EnWIF02m7Rs0kTCbkoFPIo= github.com/charmbracelet/huh v0.5.3-0.20240819144924-03b9fb7b7e9b/go.mod h1:AXVw0P9wv9BuniLHtdJvuzBbcfxufAJ3sgweykxEp+4= -github.com/charmbracelet/lipgloss v0.12.2-0.20240807180434-0618c73743d9 h1:gAepUCzOGTqCn9E/TqBeh29kq6I295ax9HxT0dUJSoo= -github.com/charmbracelet/lipgloss v0.12.2-0.20240807180434-0618c73743d9/go.mod h1:lVwxBOJ0KkZflL9y+DObgGY8V90IZUJ1e6jjZ+PBcnE= +github.com/charmbracelet/lipgloss v0.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA/SsA3cjw= +github.com/charmbracelet/lipgloss v0.13.0/go.mod h1:nw4zy0SBX/F/eAO1cWdcvy6qnkDUxr8Lw7dvFrAIbbY= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= github.com/charmbracelet/x/ansi v0.1.5-0.20240812190614-74518029592c h1:AYrQmylspZQMvm92p4TEOIXq45F5eWgnCnEltRt0SIQ= From 7195cf66dcc1b24e7ab37803e063ec36ad2a67fe Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 21 Aug 2024 16:35:52 -0300 Subject: [PATCH 015/198] chore: update codeowners Signed-off-by: Carlos Alexandro Becker --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 60f9b47..cd9f34c 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @maaslalani +* @charmbracelet/everyone From 926c18afedd56d3af4aafb053e4457180b03ed81 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 21 Aug 2024 16:36:05 -0300 Subject: [PATCH 016/198] chore(deps): update huh Signed-off-by: Carlos Alexandro Becker --- go.mod | 9 +++------ go.sum | 18 ++++++------------ 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/go.mod b/go.mod index 77728ee..886c119 100644 --- a/go.mod +++ b/go.mod @@ -8,11 +8,11 @@ require ( github.com/charmbracelet/bubbles v0.19.0 github.com/charmbracelet/bubbletea v0.27.0 github.com/charmbracelet/glamour v0.8.0 - github.com/charmbracelet/huh v0.5.3-0.20240819144924-03b9fb7b7e9b + github.com/charmbracelet/huh v0.5.3-0.20240821193529-5fd70815c13f github.com/charmbracelet/lipgloss v0.13.0 github.com/charmbracelet/log v0.4.0 - github.com/charmbracelet/x/ansi v0.1.5-0.20240812190614-74518029592c - github.com/charmbracelet/x/term v0.1.1 + github.com/charmbracelet/x/ansi v0.2.2 + github.com/charmbracelet/x/term v0.2.0 github.com/muesli/reflow v0.3.0 github.com/muesli/roff v0.1.0 github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a @@ -26,8 +26,6 @@ require ( github.com/aymerick/douceur v0.2.0 // indirect github.com/catppuccin/go v0.2.0 // indirect github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 // indirect - github.com/charmbracelet/x/input v0.1.3 // indirect - github.com/charmbracelet/x/windows v0.1.2 // indirect github.com/dlclark/regexp2 v1.11.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect @@ -43,7 +41,6 @@ require ( github.com/muesli/cancelreader v0.2.2 // indirect github.com/muesli/mango v0.2.0 // indirect github.com/rivo/uniseg v0.4.7 // indirect - github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect github.com/yuin/goldmark v1.7.4 // indirect github.com/yuin/goldmark-emoji v1.0.3 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect diff --git a/go.sum b/go.sum index 0afce21..fb7a761 100644 --- a/go.sum +++ b/go.sum @@ -26,24 +26,20 @@ github.com/charmbracelet/bubbletea v0.27.0 h1:Mznj+vvYuYagD9Pn2mY7fuelGvP0HAXtZY github.com/charmbracelet/bubbletea v0.27.0/go.mod h1:5MdP9XH6MbQkgGhnlxUqCNmBXf9I74KRQ8HIidRxV1Y= github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= -github.com/charmbracelet/huh v0.5.3-0.20240819144924-03b9fb7b7e9b h1:iHGpWtc+F61rFGlTd0ug+EnWIF02m7Rs0kTCbkoFPIo= -github.com/charmbracelet/huh v0.5.3-0.20240819144924-03b9fb7b7e9b/go.mod h1:AXVw0P9wv9BuniLHtdJvuzBbcfxufAJ3sgweykxEp+4= +github.com/charmbracelet/huh v0.5.3-0.20240821193529-5fd70815c13f h1:m7IAMdANioznBgHMGINf3giAIrFZpVtq2hhqII7HZxo= +github.com/charmbracelet/huh v0.5.3-0.20240821193529-5fd70815c13f/go.mod h1:OZC3lshuF+/y8laj//DoZdFSHxC51OrtXLJI8xWVouQ= github.com/charmbracelet/lipgloss v0.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA/SsA3cjw= github.com/charmbracelet/lipgloss v0.13.0/go.mod h1:nw4zy0SBX/F/eAO1cWdcvy6qnkDUxr8Lw7dvFrAIbbY= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= -github.com/charmbracelet/x/ansi v0.1.5-0.20240812190614-74518029592c h1:AYrQmylspZQMvm92p4TEOIXq45F5eWgnCnEltRt0SIQ= -github.com/charmbracelet/x/ansi v0.1.5-0.20240812190614-74518029592c/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= +github.com/charmbracelet/x/ansi v0.2.2 h1:BC7xzaVpfWIYZRNE8NhO9zo8KA4eGUL6L/JWXDh3GF0= +github.com/charmbracelet/x/ansi v0.2.2/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 h1:qko3AQ4gK1MTS/de7F5hPGx6/k1u0w4TeYmBFwzYVP4= github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0/go.mod h1:pBhA0ybfXv6hDjQUZ7hk1lVxBiUbupdw5R31yPUViVQ= -github.com/charmbracelet/x/input v0.1.3 h1:oy4TMhyGQsYs/WWJwu1ELUMFnjiUAXwtDf048fHbCkg= -github.com/charmbracelet/x/input v0.1.3/go.mod h1:1gaCOyw1KI9e2j00j/BBZ4ErzRZqa05w0Ghn83yIhKU= -github.com/charmbracelet/x/term v0.1.1 h1:3cosVAiPOig+EV4X9U+3LDgtwwAoEzJjNdwbXDjF6yI= -github.com/charmbracelet/x/term v0.1.1/go.mod h1:wB1fHt5ECsu3mXYusyzcngVWWlu1KKUmmLhfgr/Flxw= -github.com/charmbracelet/x/windows v0.1.2 h1:Iumiwq2G+BRmgoayww/qfcvof7W/3uLoelhxojXlRWg= -github.com/charmbracelet/x/windows v0.1.2/go.mod h1:GLEO/l+lizvFDBPLIOk+49gdX49L9YWMB5t+DZd0jkQ= +github.com/charmbracelet/x/term v0.2.0 h1:cNB9Ot9q8I711MyZ7myUR5HFWL/lc3OpU8jZ4hwm0x0= +github.com/charmbracelet/x/term v0.2.0/go.mod h1:GVxgxAbjUrmpvIINHIQnJJKpMlHiZ4cktEQCN6GWyF0= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI= @@ -95,8 +91,6 @@ github.com/sahilm/fuzzy v0.1.1 h1:ceu5RHF8DGgoi+/dR5PsECjCDH1BE3Fnmpo7aVXOdRA= github.com/sahilm/fuzzy v0.1.1/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= -github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= github.com/yuin/goldmark v1.7.4 h1:BDXOHExt+A7gwPCJgPIIq7ENvceR7we7rOS9TNoLZeg= github.com/yuin/goldmark v1.7.4/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= From 9c1128985e5641158f3177e72cda2b10184b8b58 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 23 Aug 2024 10:44:10 -0300 Subject: [PATCH 017/198] chore(deps): huh@latest Signed-off-by: Carlos Alexandro Becker --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 886c119..b6afba7 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/charmbracelet/bubbles v0.19.0 github.com/charmbracelet/bubbletea v0.27.0 github.com/charmbracelet/glamour v0.8.0 - github.com/charmbracelet/huh v0.5.3-0.20240821193529-5fd70815c13f + github.com/charmbracelet/huh v0.5.3 github.com/charmbracelet/lipgloss v0.13.0 github.com/charmbracelet/log v0.4.0 github.com/charmbracelet/x/ansi v0.2.2 diff --git a/go.sum b/go.sum index fb7a761..564072e 100644 --- a/go.sum +++ b/go.sum @@ -26,8 +26,8 @@ github.com/charmbracelet/bubbletea v0.27.0 h1:Mznj+vvYuYagD9Pn2mY7fuelGvP0HAXtZY github.com/charmbracelet/bubbletea v0.27.0/go.mod h1:5MdP9XH6MbQkgGhnlxUqCNmBXf9I74KRQ8HIidRxV1Y= github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= -github.com/charmbracelet/huh v0.5.3-0.20240821193529-5fd70815c13f h1:m7IAMdANioznBgHMGINf3giAIrFZpVtq2hhqII7HZxo= -github.com/charmbracelet/huh v0.5.3-0.20240821193529-5fd70815c13f/go.mod h1:OZC3lshuF+/y8laj//DoZdFSHxC51OrtXLJI8xWVouQ= +github.com/charmbracelet/huh v0.5.3 h1:3KLP4a/K1/S4dq4xFMTNMt3XWhgMl/yx8NYtygQ0bmg= +github.com/charmbracelet/huh v0.5.3/go.mod h1:OZC3lshuF+/y8laj//DoZdFSHxC51OrtXLJI8xWVouQ= github.com/charmbracelet/lipgloss v0.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA/SsA3cjw= github.com/charmbracelet/lipgloss v0.13.0/go.mod h1:nw4zy0SBX/F/eAO1cWdcvy6qnkDUxr8Lw7dvFrAIbbY= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= From 6837ed2d4580ed50d18e4e324c750a56ee42e178 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 29 Aug 2024 08:46:53 -0300 Subject: [PATCH 018/198] feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661) Bumps [github.com/charmbracelet/bubbletea](https://github.com/charmbracelet/bubbletea) from 0.27.0 to 1.0.0. - [Release notes](https://github.com/charmbracelet/bubbletea/releases) - [Changelog](https://github.com/charmbracelet/bubbletea/blob/main/.goreleaser.yml) - [Commits](https://github.com/charmbracelet/bubbletea/compare/v0.27.0...v1.0.0) --- updated-dependencies: - dependency-name: github.com/charmbracelet/bubbletea dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b6afba7..c708164 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/alecthomas/kong v0.9.0 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.19.0 - github.com/charmbracelet/bubbletea v0.27.0 + github.com/charmbracelet/bubbletea v1.0.0 github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/huh v0.5.3 github.com/charmbracelet/lipgloss v0.13.0 diff --git a/go.sum b/go.sum index 564072e..9efb41c 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/catppuccin/go v0.2.0 h1:ktBeIrIP42b/8FGiScP9sgrWOss3lw0Z5SktRoithGA= github.com/catppuccin/go v0.2.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc= github.com/charmbracelet/bubbles v0.19.0 h1:gKZkKXPP6GlDk6EcfujDK19PCQqRjaJZQ7QRERx1UF0= github.com/charmbracelet/bubbles v0.19.0/go.mod h1:WILteEqZ+krG5c3ntGEMeG99nCupcuIk7V0/zOP0tOA= -github.com/charmbracelet/bubbletea v0.27.0 h1:Mznj+vvYuYagD9Pn2mY7fuelGvP0HAXtZYGgRBCbHvU= -github.com/charmbracelet/bubbletea v0.27.0/go.mod h1:5MdP9XH6MbQkgGhnlxUqCNmBXf9I74KRQ8HIidRxV1Y= +github.com/charmbracelet/bubbletea v1.0.0 h1:BlNvkVed3DADQlV+W79eioNUOrnMUY25EEVdFUoDoGA= +github.com/charmbracelet/bubbletea v1.0.0/go.mod h1:xc4gm5yv+7tbniEvQ0naiG9P3fzYhk16cTgDZQQW6YE= github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= github.com/charmbracelet/huh v0.5.3 h1:3KLP4a/K1/S4dq4xFMTNMt3XWhgMl/yx8NYtygQ0bmg= From a30dda54eb0ac32efe017e19e4e3693f078a5fa9 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Thu, 29 Aug 2024 08:47:15 -0300 Subject: [PATCH 019/198] build: fix goreleaser version Signed-off-by: Carlos Alexandro Becker --- .goreleaser.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.goreleaser.yml b/.goreleaser.yml index 7bad023..b478db6 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,5 +1,7 @@ # yaml-language-server: $schema=https://goreleaser.com/static/schema-pro.json +version: 2 + includes: - from_url: url: charmbracelet/meta/main/goreleaser-full.yaml From 65e46d6e84d8d677fe30f4cd45586e66d3bc088b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Sep 2024 15:02:03 +0000 Subject: [PATCH 020/198] feat(deps): bump github.com/charmbracelet/x/ansi from 0.2.2 to 0.2.3 (#656) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index c708164..a64aacf 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/charmbracelet/huh v0.5.3 github.com/charmbracelet/lipgloss v0.13.0 github.com/charmbracelet/log v0.4.0 - github.com/charmbracelet/x/ansi v0.2.2 + github.com/charmbracelet/x/ansi v0.2.3 github.com/charmbracelet/x/term v0.2.0 github.com/muesli/reflow v0.3.0 github.com/muesli/roff v0.1.0 diff --git a/go.sum b/go.sum index 9efb41c..152d0f9 100644 --- a/go.sum +++ b/go.sum @@ -32,8 +32,8 @@ github.com/charmbracelet/lipgloss v0.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA github.com/charmbracelet/lipgloss v0.13.0/go.mod h1:nw4zy0SBX/F/eAO1cWdcvy6qnkDUxr8Lw7dvFrAIbbY= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= -github.com/charmbracelet/x/ansi v0.2.2 h1:BC7xzaVpfWIYZRNE8NhO9zo8KA4eGUL6L/JWXDh3GF0= -github.com/charmbracelet/x/ansi v0.2.2/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= +github.com/charmbracelet/x/ansi v0.2.3 h1:VfFN0NUpcjBRd4DnKfRaIRo53KRgey/nhOoEqosGDEY= +github.com/charmbracelet/x/ansi v0.2.3/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 h1:qko3AQ4gK1MTS/de7F5hPGx6/k1u0w4TeYmBFwzYVP4= From 8ab6253ca117a625132f5e430c7a5559490e737a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Sep 2024 12:06:13 -0300 Subject: [PATCH 021/198] feat(deps): bump github.com/charmbracelet/bubbletea from 1.0.0 to 1.1.0 (#665) Bumps [github.com/charmbracelet/bubbletea](https://github.com/charmbracelet/bubbletea) from 1.0.0 to 1.1.0. - [Release notes](https://github.com/charmbracelet/bubbletea/releases) - [Changelog](https://github.com/charmbracelet/bubbletea/blob/main/.goreleaser.yml) - [Commits](https://github.com/charmbracelet/bubbletea/compare/v1.0.0...v1.1.0) --- updated-dependencies: - dependency-name: github.com/charmbracelet/bubbletea dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a64aacf..915d0d5 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/alecthomas/kong v0.9.0 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.19.0 - github.com/charmbracelet/bubbletea v1.0.0 + github.com/charmbracelet/bubbletea v1.1.0 github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/huh v0.5.3 github.com/charmbracelet/lipgloss v0.13.0 diff --git a/go.sum b/go.sum index 152d0f9..70d818e 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/catppuccin/go v0.2.0 h1:ktBeIrIP42b/8FGiScP9sgrWOss3lw0Z5SktRoithGA= github.com/catppuccin/go v0.2.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc= github.com/charmbracelet/bubbles v0.19.0 h1:gKZkKXPP6GlDk6EcfujDK19PCQqRjaJZQ7QRERx1UF0= github.com/charmbracelet/bubbles v0.19.0/go.mod h1:WILteEqZ+krG5c3ntGEMeG99nCupcuIk7V0/zOP0tOA= -github.com/charmbracelet/bubbletea v1.0.0 h1:BlNvkVed3DADQlV+W79eioNUOrnMUY25EEVdFUoDoGA= -github.com/charmbracelet/bubbletea v1.0.0/go.mod h1:xc4gm5yv+7tbniEvQ0naiG9P3fzYhk16cTgDZQQW6YE= +github.com/charmbracelet/bubbletea v1.1.0 h1:FjAl9eAL3HBCHenhz/ZPjkKdScmaS5SK69JAK2YJK9c= +github.com/charmbracelet/bubbletea v1.1.0/go.mod h1:9Ogk0HrdbHolIKHdjfFpyXJmiCzGwy+FesYkZr7hYU4= github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= github.com/charmbracelet/huh v0.5.3 h1:3KLP4a/K1/S4dq4xFMTNMt3XWhgMl/yx8NYtygQ0bmg= From b9611e1d8300c9a76380275e87d2862f4779ddf7 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 6 Sep 2024 12:06:27 -0300 Subject: [PATCH 022/198] fix: lint issues (#663) --- .golangci-soft.yml | 9 +-------- .golangci.yml | 1 - choose/command.go | 8 ++++---- filter/filter.go | 16 ++++++++-------- 4 files changed, 13 insertions(+), 21 deletions(-) diff --git a/.golangci-soft.yml b/.golangci-soft.yml index 01d7797..82c337e 100644 --- a/.golangci-soft.yml +++ b/.golangci-soft.yml @@ -14,17 +14,13 @@ issues: linters: enable: - # - dupl - exhaustive - # - exhaustivestruct - goconst - godot - godox - - gomnd + - mnd - gomoddirectives - goprintffuncname - # - ifshort - # - lll - misspell - nakedret - nestif @@ -35,12 +31,9 @@ linters: # disable default linters, they are already enabled in .golangci.yml disable: - wrapcheck - - deadcode - errcheck - gosimple - govet - ineffassign - staticcheck - - structcheck - typecheck - - varcheck diff --git a/.golangci.yml b/.golangci.yml index a5a91d0..684d54b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -15,7 +15,6 @@ issues: linters: enable: - bodyclose - - exportloopref - goimports - gosec - nilerr diff --git a/choose/command.go b/choose/command.go index 38937c2..8fe7773 100644 --- a/choose/command.go +++ b/choose/command.go @@ -116,14 +116,14 @@ func (o Options) Run() error { } func widest(options []string) int { - var max int + var maxw int for _, o := range options { w := lipgloss.Width(o) - if w > max { - max = w + if w > maxw { + maxw = w } } - return max + return maxw } func ansiprint(s string) { diff --git a/filter/filter.go b/filter/filter.go index 92b5677..3ed1e78 100644 --- a/filter/filter.go +++ b/filter/filter.go @@ -56,6 +56,7 @@ type model struct { func (m model) Init() tea.Cmd { return timeout.Init(m.timeout, nil) } + func (m model) View() string { if m.quitting { return "" @@ -254,7 +255,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } func (m *model) CursorUp() { - if m.reverse { + if m.reverse { //nolint:nestif m.cursor = (m.cursor + 1) % len(m.matches) if len(m.matches)-m.cursor <= m.viewport.YOffset { m.viewport.LineUp(1) @@ -274,7 +275,7 @@ func (m *model) CursorUp() { } func (m *model) CursorDown() { - if m.reverse { + if m.reverse { //nolint:nestif m.cursor = (m.cursor - 1 + len(m.matches)) % len(m.matches) if len(m.matches)-m.cursor > m.viewport.Height+m.viewport.YOffset { m.viewport.LineDown(1) @@ -334,13 +335,12 @@ func exactMatches(search string, choices []string) []fuzzy.Match { return matches } -//nolint:unparam -func clamp(min, max, val int) int { - if val < min { - return min +func clamp(low, high, val int) int { + if val < low { + return low } - if val > max { - return max + if val > high { + return high } return val } From f0bd6f4b455aa1a11ad64dccf8144a63583397e4 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 6 Sep 2024 13:39:11 -0300 Subject: [PATCH 023/198] chore(deps): update Signed-off-by: Carlos Alexandro Becker --- go.mod | 8 ++++---- go.sum | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 915d0d5..efdd8c4 100644 --- a/go.mod +++ b/go.mod @@ -5,10 +5,10 @@ go 1.21 require ( github.com/alecthomas/kong v0.9.0 github.com/alecthomas/mango-kong v0.1.0 - github.com/charmbracelet/bubbles v0.19.0 + github.com/charmbracelet/bubbles v0.20.0 github.com/charmbracelet/bubbletea v1.1.0 github.com/charmbracelet/glamour v0.8.0 - github.com/charmbracelet/huh v0.5.3 + github.com/charmbracelet/huh v0.6.0 github.com/charmbracelet/lipgloss v0.13.0 github.com/charmbracelet/log v0.4.0 github.com/charmbracelet/x/ansi v0.2.3 @@ -46,7 +46,7 @@ require ( golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/net v0.27.0 // indirect golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.24.0 // indirect + golang.org/x/sys v0.25.0 // indirect golang.org/x/term v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/text v0.18.0 // indirect ) diff --git a/go.sum b/go.sum index 70d818e..c53018e 100644 --- a/go.sum +++ b/go.sum @@ -20,14 +20,14 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/catppuccin/go v0.2.0 h1:ktBeIrIP42b/8FGiScP9sgrWOss3lw0Z5SktRoithGA= github.com/catppuccin/go v0.2.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc= -github.com/charmbracelet/bubbles v0.19.0 h1:gKZkKXPP6GlDk6EcfujDK19PCQqRjaJZQ7QRERx1UF0= -github.com/charmbracelet/bubbles v0.19.0/go.mod h1:WILteEqZ+krG5c3ntGEMeG99nCupcuIk7V0/zOP0tOA= +github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE= +github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU= github.com/charmbracelet/bubbletea v1.1.0 h1:FjAl9eAL3HBCHenhz/ZPjkKdScmaS5SK69JAK2YJK9c= github.com/charmbracelet/bubbletea v1.1.0/go.mod h1:9Ogk0HrdbHolIKHdjfFpyXJmiCzGwy+FesYkZr7hYU4= github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= -github.com/charmbracelet/huh v0.5.3 h1:3KLP4a/K1/S4dq4xFMTNMt3XWhgMl/yx8NYtygQ0bmg= -github.com/charmbracelet/huh v0.5.3/go.mod h1:OZC3lshuF+/y8laj//DoZdFSHxC51OrtXLJI8xWVouQ= +github.com/charmbracelet/huh v0.6.0 h1:mZM8VvZGuE0hoDXq6XLxRtgfWyTI3b2jZNKh0xWmax8= +github.com/charmbracelet/huh v0.6.0/go.mod h1:GGNKeWCeNzKpEOh/OJD8WBwTQjV3prFAtQPpLv+AVwU= github.com/charmbracelet/lipgloss v0.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA/SsA3cjw= github.com/charmbracelet/lipgloss v0.13.0/go.mod h1:nw4zy0SBX/F/eAO1cWdcvy6qnkDUxr8Lw7dvFrAIbbY= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= @@ -104,11 +104,11 @@ golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 19170239015a0a3c865d6f87db2cb286d677964c Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 6 Sep 2024 13:39:31 -0300 Subject: [PATCH 024/198] ci: fix dependabot config Signed-off-by: Carlos Alexandro Becker --- .github/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 9fc3b07..c0e481b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,7 +7,7 @@ updates: labels: - "dependencies" commit-message: - prefix: "feat" + prefix: "chore" include: "scope" - package-ecosystem: "github-actions" directory: "/" From 40889fecd955d4525388ddb8b42a69781fdc67b4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 12:06:27 -0300 Subject: [PATCH 025/198] chore(deps): bump github.com/alecthomas/kong from 0.9.0 to 1.2.1 (#674) Bumps [github.com/alecthomas/kong](https://github.com/alecthomas/kong) from 0.9.0 to 1.2.1. - [Commits](https://github.com/alecthomas/kong/compare/v0.9.0...v1.2.1) --- updated-dependencies: - dependency-name: github.com/alecthomas/kong dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index efdd8c4..4dbaee7 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/charmbracelet/gum go 1.21 require ( - github.com/alecthomas/kong v0.9.0 + github.com/alecthomas/kong v1.2.1 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 github.com/charmbracelet/bubbletea v1.1.0 diff --git a/go.sum b/go.sum index c53018e..dd19c47 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,11 @@ github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= -github.com/alecthomas/assert/v2 v2.7.0 h1:QtqSACNS3tF7oasA8CU6A6sXZSBDqnm7RfpLl9bZqbE= -github.com/alecthomas/assert/v2 v2.7.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= +github.com/alecthomas/assert/v2 v2.10.0 h1:jjRCHsj6hBJhkmhznrCzoNpbA3zqy0fYiUcYZP/GkPY= +github.com/alecthomas/assert/v2 v2.10.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E= github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I= -github.com/alecthomas/kong v0.9.0 h1:G5diXxc85KvoV2f0ZRVuMsi45IrBgx9zDNGNj165aPA= -github.com/alecthomas/kong v0.9.0/go.mod h1:Y47y5gKfHp1hDc7CH7OeXgLIpp+Q2m1Ni0L5s3bI8Os= +github.com/alecthomas/kong v1.2.1 h1:E8jH4Tsgv6wCRX2nGrdPyHDUCSG83WH2qE4XLACD33Q= +github.com/alecthomas/kong v1.2.1/go.mod h1:rKTSFhbdp3Ryefn8x5MOEprnRFQ7nlmMC01GKhehhBM= github.com/alecthomas/mango-kong v0.1.0 h1:iFVfP1k1K4qpml3JUQmD5I8MCQYfIvsD9mRdrw7jJC4= github.com/alecthomas/mango-kong v0.1.0/go.mod h1:t+TYVdsONUolf/BwVcm+15eqcdAj15h4Qe9MMFAwwT4= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= From 73a7be24fc05f03da18a3c64f8968dce23f964ae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 12:06:45 -0300 Subject: [PATCH 026/198] chore(deps): bump github.com/charmbracelet/bubbletea from 1.1.0 to 1.1.1 (#672) Bumps [github.com/charmbracelet/bubbletea](https://github.com/charmbracelet/bubbletea) from 1.1.0 to 1.1.1. - [Release notes](https://github.com/charmbracelet/bubbletea/releases) - [Changelog](https://github.com/charmbracelet/bubbletea/blob/main/.goreleaser.yml) - [Commits](https://github.com/charmbracelet/bubbletea/compare/v1.1.0...v1.1.1) --- updated-dependencies: - dependency-name: github.com/charmbracelet/bubbletea dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4dbaee7..2cee6f4 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/alecthomas/kong v1.2.1 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 - github.com/charmbracelet/bubbletea v1.1.0 + github.com/charmbracelet/bubbletea v1.1.1 github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/huh v0.6.0 github.com/charmbracelet/lipgloss v0.13.0 diff --git a/go.sum b/go.sum index dd19c47..20d19c6 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/catppuccin/go v0.2.0 h1:ktBeIrIP42b/8FGiScP9sgrWOss3lw0Z5SktRoithGA= github.com/catppuccin/go v0.2.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc= github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE= github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU= -github.com/charmbracelet/bubbletea v1.1.0 h1:FjAl9eAL3HBCHenhz/ZPjkKdScmaS5SK69JAK2YJK9c= -github.com/charmbracelet/bubbletea v1.1.0/go.mod h1:9Ogk0HrdbHolIKHdjfFpyXJmiCzGwy+FesYkZr7hYU4= +github.com/charmbracelet/bubbletea v1.1.1 h1:KJ2/DnmpfqFtDNVTvYZ6zpPFL9iRCRr0qqKOCvppbPY= +github.com/charmbracelet/bubbletea v1.1.1/go.mod h1:9Ogk0HrdbHolIKHdjfFpyXJmiCzGwy+FesYkZr7hYU4= github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= github.com/charmbracelet/huh v0.6.0 h1:mZM8VvZGuE0hoDXq6XLxRtgfWyTI3b2jZNKh0xWmax8= From c00c2e416acd374423c5661341cff2e50ce23214 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 12:06:57 -0300 Subject: [PATCH 027/198] chore(deps): bump github.com/charmbracelet/x/ansi from 0.2.3 to 0.3.0 (#673) Bumps [github.com/charmbracelet/x/ansi](https://github.com/charmbracelet/x) from 0.2.3 to 0.3.0. - [Release notes](https://github.com/charmbracelet/x/releases) - [Commits](https://github.com/charmbracelet/x/compare/ansi/v0.2.3...ansi/v0.3.0) --- updated-dependencies: - dependency-name: github.com/charmbracelet/x/ansi dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2cee6f4..46fb167 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/charmbracelet/huh v0.6.0 github.com/charmbracelet/lipgloss v0.13.0 github.com/charmbracelet/log v0.4.0 - github.com/charmbracelet/x/ansi v0.2.3 + github.com/charmbracelet/x/ansi v0.3.0 github.com/charmbracelet/x/term v0.2.0 github.com/muesli/reflow v0.3.0 github.com/muesli/roff v0.1.0 diff --git a/go.sum b/go.sum index 20d19c6..456c906 100644 --- a/go.sum +++ b/go.sum @@ -32,8 +32,8 @@ github.com/charmbracelet/lipgloss v0.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA github.com/charmbracelet/lipgloss v0.13.0/go.mod h1:nw4zy0SBX/F/eAO1cWdcvy6qnkDUxr8Lw7dvFrAIbbY= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= -github.com/charmbracelet/x/ansi v0.2.3 h1:VfFN0NUpcjBRd4DnKfRaIRo53KRgey/nhOoEqosGDEY= -github.com/charmbracelet/x/ansi v0.2.3/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= +github.com/charmbracelet/x/ansi v0.3.0 h1:CCsscv7vKC/DNYUYFQNNIOWzrpTUbLXL3d4fdFIQ0WE= +github.com/charmbracelet/x/ansi v0.3.0/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 h1:qko3AQ4gK1MTS/de7F5hPGx6/k1u0w4TeYmBFwzYVP4= From e06d2e69a6715e7f6f71449690122ad19b6686ed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 Sep 2024 09:38:35 -0300 Subject: [PATCH 028/198] chore(deps): bump github.com/charmbracelet/x/ansi from 0.3.0 to 0.3.2 (#679) Bumps [github.com/charmbracelet/x/ansi](https://github.com/charmbracelet/x) from 0.3.0 to 0.3.2. - [Release notes](https://github.com/charmbracelet/x/releases) - [Commits](https://github.com/charmbracelet/x/compare/ansi/v0.3.0...ansi/v0.3.2) --- updated-dependencies: - dependency-name: github.com/charmbracelet/x/ansi dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 46fb167..99131c3 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/charmbracelet/huh v0.6.0 github.com/charmbracelet/lipgloss v0.13.0 github.com/charmbracelet/log v0.4.0 - github.com/charmbracelet/x/ansi v0.3.0 + github.com/charmbracelet/x/ansi v0.3.2 github.com/charmbracelet/x/term v0.2.0 github.com/muesli/reflow v0.3.0 github.com/muesli/roff v0.1.0 diff --git a/go.sum b/go.sum index 456c906..7210a2a 100644 --- a/go.sum +++ b/go.sum @@ -32,8 +32,8 @@ github.com/charmbracelet/lipgloss v0.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA github.com/charmbracelet/lipgloss v0.13.0/go.mod h1:nw4zy0SBX/F/eAO1cWdcvy6qnkDUxr8Lw7dvFrAIbbY= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= -github.com/charmbracelet/x/ansi v0.3.0 h1:CCsscv7vKC/DNYUYFQNNIOWzrpTUbLXL3d4fdFIQ0WE= -github.com/charmbracelet/x/ansi v0.3.0/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= +github.com/charmbracelet/x/ansi v0.3.2 h1:wsEwgAN+C9U06l9dCVMX0/L3x7ptvY1qmjMwyfE6USY= +github.com/charmbracelet/x/ansi v0.3.2/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 h1:qko3AQ4gK1MTS/de7F5hPGx6/k1u0w4TeYmBFwzYVP4= From 8c7abe73354865091e95a00c73f3dcb0545803df Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 17 Sep 2024 09:40:12 -0300 Subject: [PATCH 029/198] fix: lint issues Signed-off-by: Carlos Alexandro Becker --- pager/pager.go | 4 ++-- pager/search.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pager/pager.go b/pager/pager.go index ca24fc6..f55201b 100644 --- a/pager/pager.go +++ b/pager/pager.go @@ -76,7 +76,7 @@ func (m *model) ProcessText(msg tea.WindowSizeMsg) { text.WriteString(m.lineNumberStyle.Render(fmt.Sprintf("%4d │ ", i+1))) } for m.softWrap && lipgloss.Width(line) > m.maxWidth { - truncatedLine := truncate.String(line, uint(m.maxWidth)) + truncatedLine := truncate.String(line, uint(m.maxWidth)) //nolint: gosec text.WriteString(textStyle.Render(truncatedLine)) text.WriteString("\n") if m.showLineNumbers { @@ -84,7 +84,7 @@ func (m *model) ProcessText(msg tea.WindowSizeMsg) { } line = strings.Replace(line, truncatedLine, "", 1) } - text.WriteString(textStyle.Render(truncate.String(line, uint(m.maxWidth)))) + text.WriteString(textStyle.Render(truncate.String(line, uint(m.maxWidth)))) //nolint: gosec text.WriteString("\n") } diff --git a/pager/search.go b/pager/search.go index b112d7d..e32260d 100644 --- a/pager/search.go +++ b/pager/search.go @@ -151,12 +151,12 @@ func softWrapEm(str string, maxWidth int, softWrap bool) string { var text strings.Builder for _, line := range strings.Split(str, "\n") { for softWrap && lipgloss.Width(line) > maxWidth { - truncatedLine := truncate.String(line, uint(maxWidth)) + truncatedLine := truncate.String(line, uint(maxWidth)) //nolint: gosec text.WriteString(truncatedLine) text.WriteString("\n") line = strings.Replace(line, truncatedLine, "", 1) } - text.WriteString(truncate.String(line, uint(maxWidth))) + text.WriteString(truncate.String(line, uint(maxWidth))) //nolint: gosec text.WriteString("\n") } From b5b20c50316d8369e935430898a972c5dd4b4881 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 11:57:16 +0000 Subject: [PATCH 030/198] chore(deps): bump github.com/charmbracelet/bubbletea from 1.1.1 to 1.1.2 (#694) --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 99131c3..2b135f2 100644 --- a/go.mod +++ b/go.mod @@ -6,12 +6,12 @@ require ( github.com/alecthomas/kong v1.2.1 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 - github.com/charmbracelet/bubbletea v1.1.1 + github.com/charmbracelet/bubbletea v1.1.2 github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/huh v0.6.0 github.com/charmbracelet/lipgloss v0.13.0 github.com/charmbracelet/log v0.4.0 - github.com/charmbracelet/x/ansi v0.3.2 + github.com/charmbracelet/x/ansi v0.4.0 github.com/charmbracelet/x/term v0.2.0 github.com/muesli/reflow v0.3.0 github.com/muesli/roff v0.1.0 @@ -46,7 +46,7 @@ require ( golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/net v0.27.0 // indirect golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.25.0 // indirect + golang.org/x/sys v0.26.0 // indirect golang.org/x/term v0.22.0 // indirect golang.org/x/text v0.18.0 // indirect ) diff --git a/go.sum b/go.sum index 7210a2a..e6673d9 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/catppuccin/go v0.2.0 h1:ktBeIrIP42b/8FGiScP9sgrWOss3lw0Z5SktRoithGA= github.com/catppuccin/go v0.2.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc= github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE= github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU= -github.com/charmbracelet/bubbletea v1.1.1 h1:KJ2/DnmpfqFtDNVTvYZ6zpPFL9iRCRr0qqKOCvppbPY= -github.com/charmbracelet/bubbletea v1.1.1/go.mod h1:9Ogk0HrdbHolIKHdjfFpyXJmiCzGwy+FesYkZr7hYU4= +github.com/charmbracelet/bubbletea v1.1.2 h1:naQXF2laRxyLyil/i7fxdpiz1/k06IKquhm4vBfHsIc= +github.com/charmbracelet/bubbletea v1.1.2/go.mod h1:9HIU/hBV24qKjlehyj8z1r/tR9TYTQEag+cWZnuXo8E= github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= github.com/charmbracelet/huh v0.6.0 h1:mZM8VvZGuE0hoDXq6XLxRtgfWyTI3b2jZNKh0xWmax8= @@ -32,8 +32,8 @@ github.com/charmbracelet/lipgloss v0.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA github.com/charmbracelet/lipgloss v0.13.0/go.mod h1:nw4zy0SBX/F/eAO1cWdcvy6qnkDUxr8Lw7dvFrAIbbY= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= -github.com/charmbracelet/x/ansi v0.3.2 h1:wsEwgAN+C9U06l9dCVMX0/L3x7ptvY1qmjMwyfE6USY= -github.com/charmbracelet/x/ansi v0.3.2/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= +github.com/charmbracelet/x/ansi v0.4.0 h1:NqwHA4B23VwsDn4H3VcNX1W1tOmgnvY1NDx5tOXdnOU= +github.com/charmbracelet/x/ansi v0.4.0/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 h1:qko3AQ4gK1MTS/de7F5hPGx6/k1u0w4TeYmBFwzYVP4= @@ -104,8 +104,8 @@ golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= -golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= From 4323b2e750575e80f29aefd4a0197cc0ffb73f01 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 12:08:17 +0000 Subject: [PATCH 031/198] chore(deps): bump github.com/charmbracelet/lipgloss (#692) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2b135f2..1eef34e 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/charmbracelet/bubbletea v1.1.2 github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/huh v0.6.0 - github.com/charmbracelet/lipgloss v0.13.0 + github.com/charmbracelet/lipgloss v0.13.1 github.com/charmbracelet/log v0.4.0 github.com/charmbracelet/x/ansi v0.4.0 github.com/charmbracelet/x/term v0.2.0 diff --git a/go.sum b/go.sum index e6673d9..00402f1 100644 --- a/go.sum +++ b/go.sum @@ -28,8 +28,8 @@ github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= github.com/charmbracelet/huh v0.6.0 h1:mZM8VvZGuE0hoDXq6XLxRtgfWyTI3b2jZNKh0xWmax8= github.com/charmbracelet/huh v0.6.0/go.mod h1:GGNKeWCeNzKpEOh/OJD8WBwTQjV3prFAtQPpLv+AVwU= -github.com/charmbracelet/lipgloss v0.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA/SsA3cjw= -github.com/charmbracelet/lipgloss v0.13.0/go.mod h1:nw4zy0SBX/F/eAO1cWdcvy6qnkDUxr8Lw7dvFrAIbbY= +github.com/charmbracelet/lipgloss v0.13.1 h1:Oik/oqDTMVA01GetT4JdEC033dNzWoQHdWnHnQmXE2A= +github.com/charmbracelet/lipgloss v0.13.1/go.mod h1:zaYVJ2xKSKEnTEEbX6uAHabh2d975RJ+0yfkFpRBz5U= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= github.com/charmbracelet/x/ansi v0.4.0 h1:NqwHA4B23VwsDn4H3VcNX1W1tOmgnvY1NDx5tOXdnOU= From 1023911ea2fe9f05c4fd0d44a104545ad205faae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 30 Oct 2024 04:05:34 +0000 Subject: [PATCH 032/198] chore(deps): bump github.com/charmbracelet/x/ansi from 0.4.0 to 0.4.2 Bumps [github.com/charmbracelet/x/ansi](https://github.com/charmbracelet/x) from 0.4.0 to 0.4.2. - [Release notes](https://github.com/charmbracelet/x/releases) - [Commits](https://github.com/charmbracelet/x/compare/ansi/v0.4.0...ansi/v0.4.2) --- updated-dependencies: - dependency-name: github.com/charmbracelet/x/ansi dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 1eef34e..4e520e1 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/charmbracelet/huh v0.6.0 github.com/charmbracelet/lipgloss v0.13.1 github.com/charmbracelet/log v0.4.0 - github.com/charmbracelet/x/ansi v0.4.0 + github.com/charmbracelet/x/ansi v0.4.2 github.com/charmbracelet/x/term v0.2.0 github.com/muesli/reflow v0.3.0 github.com/muesli/roff v0.1.0 diff --git a/go.sum b/go.sum index 00402f1..f6b3253 100644 --- a/go.sum +++ b/go.sum @@ -32,8 +32,8 @@ github.com/charmbracelet/lipgloss v0.13.1 h1:Oik/oqDTMVA01GetT4JdEC033dNzWoQHdWn github.com/charmbracelet/lipgloss v0.13.1/go.mod h1:zaYVJ2xKSKEnTEEbX6uAHabh2d975RJ+0yfkFpRBz5U= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= -github.com/charmbracelet/x/ansi v0.4.0 h1:NqwHA4B23VwsDn4H3VcNX1W1tOmgnvY1NDx5tOXdnOU= -github.com/charmbracelet/x/ansi v0.4.0/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= +github.com/charmbracelet/x/ansi v0.4.2 h1:0JM6Aj/g/KC154/gOP4vfxun0ff6itogDYk41kof+qk= +github.com/charmbracelet/x/ansi v0.4.2/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 h1:qko3AQ4gK1MTS/de7F5hPGx6/k1u0w4TeYmBFwzYVP4= From ac3f44a9dbe028c562a972b2f4e67a2aa58fa757 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Thu, 7 Nov 2024 13:19:56 -0300 Subject: [PATCH 033/198] fix(deps): update goldmark-emoji (#686) refs #331 Signed-off-by: Carlos Alexandro Becker --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4e520e1..5051516 100644 --- a/go.mod +++ b/go.mod @@ -42,7 +42,7 @@ require ( github.com/muesli/mango v0.2.0 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/yuin/goldmark v1.7.4 // indirect - github.com/yuin/goldmark-emoji v1.0.3 // indirect + github.com/yuin/goldmark-emoji v1.0.4 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/net v0.27.0 // indirect golang.org/x/sync v0.8.0 // indirect diff --git a/go.sum b/go.sum index f6b3253..15cf5d9 100644 --- a/go.sum +++ b/go.sum @@ -94,8 +94,8 @@ github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8 github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= github.com/yuin/goldmark v1.7.4 h1:BDXOHExt+A7gwPCJgPIIq7ENvceR7we7rOS9TNoLZeg= github.com/yuin/goldmark v1.7.4/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= -github.com/yuin/goldmark-emoji v1.0.3 h1:aLRkLHOuBR2czCY4R8olwMjID+tENfhyFDMCRhbIQY4= -github.com/yuin/goldmark-emoji v1.0.3/go.mod h1:tTkZEbwu5wkPmgTcitqddVxY9osFZiavD+r4AzQrh1U= +github.com/yuin/goldmark-emoji v1.0.4 h1:vCwMkPZSNefSUnOW2ZKRUjBSD5Ok3W78IXhGxxAEF90= +github.com/yuin/goldmark-emoji v1.0.4/go.mod h1:tTkZEbwu5wkPmgTcitqddVxY9osFZiavD+r4AzQrh1U= golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY= golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= From b8f99b6053741bbe4fc1a00785ad6ca01dd59be6 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Thu, 7 Nov 2024 13:28:31 -0300 Subject: [PATCH 034/198] ci: update --- .github/workflows/build.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5a74cbb..5be3fe8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,3 +32,22 @@ jobs: uses: charmbracelet/meta/.github/workflows/snapshot.yml@main secrets: goreleaser_key: ${{ secrets.GORELEASER_KEY }} + + dependabot: + needs: [build] + runs-on: ubuntu-latest + permissions: + pull-requests: write + contents: write + if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request'}} + steps: + - id: metadata + uses: dependabot/fetch-metadata@v2 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + - run: | + gh pr review --approve "$PR_URL" + gh pr merge --squash --auto "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} From 790be1247aeea2d7828d690a7a73f0cbe8b8db6c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 04:53:45 +0000 Subject: [PATCH 035/198] chore(deps): bump github.com/charmbracelet/bubbletea from 1.1.2 to 1.2.1 (#710) Bumps [github.com/charmbracelet/bubbletea](https://github.com/charmbracelet/bubbletea) from 1.1.2 to 1.2.1. - [Release notes](https://github.com/charmbracelet/bubbletea/releases) - [Changelog](https://github.com/charmbracelet/bubbletea/blob/main/.goreleaser.yml) - [Commits](https://github.com/charmbracelet/bubbletea/compare/v1.1.2...v1.2.1) --- updated-dependencies: - dependency-name: github.com/charmbracelet/bubbletea dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 5051516..0b1029f 100644 --- a/go.mod +++ b/go.mod @@ -6,12 +6,12 @@ require ( github.com/alecthomas/kong v1.2.1 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 - github.com/charmbracelet/bubbletea v1.1.2 + github.com/charmbracelet/bubbletea v1.2.1 github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/huh v0.6.0 - github.com/charmbracelet/lipgloss v0.13.1 + github.com/charmbracelet/lipgloss v1.0.0 github.com/charmbracelet/log v0.4.0 - github.com/charmbracelet/x/ansi v0.4.2 + github.com/charmbracelet/x/ansi v0.4.5 github.com/charmbracelet/x/term v0.2.0 github.com/muesli/reflow v0.3.0 github.com/muesli/roff v0.1.0 diff --git a/go.sum b/go.sum index 15cf5d9..cf35b8f 100644 --- a/go.sum +++ b/go.sum @@ -22,18 +22,18 @@ github.com/catppuccin/go v0.2.0 h1:ktBeIrIP42b/8FGiScP9sgrWOss3lw0Z5SktRoithGA= github.com/catppuccin/go v0.2.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc= github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE= github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU= -github.com/charmbracelet/bubbletea v1.1.2 h1:naQXF2laRxyLyil/i7fxdpiz1/k06IKquhm4vBfHsIc= -github.com/charmbracelet/bubbletea v1.1.2/go.mod h1:9HIU/hBV24qKjlehyj8z1r/tR9TYTQEag+cWZnuXo8E= +github.com/charmbracelet/bubbletea v1.2.1 h1:J041h57zculJKEKf/O2pS4edXGIz+V0YvojvfGXePIk= +github.com/charmbracelet/bubbletea v1.2.1/go.mod h1:viLoDL7hG4njLJSKU2gw7kB3LSEmWsrM80rO1dBJWBI= github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= github.com/charmbracelet/huh v0.6.0 h1:mZM8VvZGuE0hoDXq6XLxRtgfWyTI3b2jZNKh0xWmax8= github.com/charmbracelet/huh v0.6.0/go.mod h1:GGNKeWCeNzKpEOh/OJD8WBwTQjV3prFAtQPpLv+AVwU= -github.com/charmbracelet/lipgloss v0.13.1 h1:Oik/oqDTMVA01GetT4JdEC033dNzWoQHdWnHnQmXE2A= -github.com/charmbracelet/lipgloss v0.13.1/go.mod h1:zaYVJ2xKSKEnTEEbX6uAHabh2d975RJ+0yfkFpRBz5U= +github.com/charmbracelet/lipgloss v1.0.0 h1:O7VkGDvqEdGi93X+DeqsQ7PKHDgtQfF8j8/O2qFMQNg= +github.com/charmbracelet/lipgloss v1.0.0/go.mod h1:U5fy9Z+C38obMs+T+tJqst9VGzlOYGj4ri9reL3qUlo= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= -github.com/charmbracelet/x/ansi v0.4.2 h1:0JM6Aj/g/KC154/gOP4vfxun0ff6itogDYk41kof+qk= -github.com/charmbracelet/x/ansi v0.4.2/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= +github.com/charmbracelet/x/ansi v0.4.5 h1:LqK4vwBNaXw2AyGIICa5/29Sbdq58GbGdFngSexTdRM= +github.com/charmbracelet/x/ansi v0.4.5/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 h1:qko3AQ4gK1MTS/de7F5hPGx6/k1u0w4TeYmBFwzYVP4= From 8a007012beafd4f94c6dbadcc942a0f1ecddc0e2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 04:55:41 +0000 Subject: [PATCH 036/198] chore(deps): bump github.com/charmbracelet/x/term from 0.2.0 to 0.2.1 (#711) Bumps [github.com/charmbracelet/x/term](https://github.com/charmbracelet/x) from 0.2.0 to 0.2.1. - [Release notes](https://github.com/charmbracelet/x/releases) - [Commits](https://github.com/charmbracelet/x/compare/ansi/v0.2.0...ansi/v0.2.1) --- updated-dependencies: - dependency-name: github.com/charmbracelet/x/term dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0b1029f..fd88845 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/charmbracelet/lipgloss v1.0.0 github.com/charmbracelet/log v0.4.0 github.com/charmbracelet/x/ansi v0.4.5 - github.com/charmbracelet/x/term v0.2.0 + github.com/charmbracelet/x/term v0.2.1 github.com/muesli/reflow v0.3.0 github.com/muesli/roff v0.1.0 github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a diff --git a/go.sum b/go.sum index cf35b8f..414bf75 100644 --- a/go.sum +++ b/go.sum @@ -38,8 +38,8 @@ github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAM github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 h1:qko3AQ4gK1MTS/de7F5hPGx6/k1u0w4TeYmBFwzYVP4= github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0/go.mod h1:pBhA0ybfXv6hDjQUZ7hk1lVxBiUbupdw5R31yPUViVQ= -github.com/charmbracelet/x/term v0.2.0 h1:cNB9Ot9q8I711MyZ7myUR5HFWL/lc3OpU8jZ4hwm0x0= -github.com/charmbracelet/x/term v0.2.0/go.mod h1:GVxgxAbjUrmpvIINHIQnJJKpMlHiZ4cktEQCN6GWyF0= +github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ= +github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI= From 03d3bcf178c04b9e546c0e6cf502ff060d8d22de Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 04:57:18 +0000 Subject: [PATCH 037/198] chore(deps): bump github.com/alecthomas/kong from 1.2.1 to 1.4.0 (#705) Bumps [github.com/alecthomas/kong](https://github.com/alecthomas/kong) from 1.2.1 to 1.4.0. - [Commits](https://github.com/alecthomas/kong/compare/v1.2.1...v1.4.0) --- updated-dependencies: - dependency-name: github.com/alecthomas/kong dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index fd88845..b9de049 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/charmbracelet/gum go 1.21 require ( - github.com/alecthomas/kong v1.2.1 + github.com/alecthomas/kong v1.4.0 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 github.com/charmbracelet/bubbletea v1.2.1 diff --git a/go.sum b/go.sum index 414bf75..2f23d09 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,11 @@ github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= -github.com/alecthomas/assert/v2 v2.10.0 h1:jjRCHsj6hBJhkmhznrCzoNpbA3zqy0fYiUcYZP/GkPY= -github.com/alecthomas/assert/v2 v2.10.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= +github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0= +github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E= github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I= -github.com/alecthomas/kong v1.2.1 h1:E8jH4Tsgv6wCRX2nGrdPyHDUCSG83WH2qE4XLACD33Q= -github.com/alecthomas/kong v1.2.1/go.mod h1:rKTSFhbdp3Ryefn8x5MOEprnRFQ7nlmMC01GKhehhBM= +github.com/alecthomas/kong v1.4.0 h1:UL7tzGMnnY0YRMMvJyITIRX1EpO6RbBRZDNcCevy3HA= +github.com/alecthomas/kong v1.4.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= github.com/alecthomas/mango-kong v0.1.0 h1:iFVfP1k1K4qpml3JUQmD5I8MCQYfIvsD9mRdrw7jJC4= github.com/alecthomas/mango-kong v0.1.0/go.mod h1:t+TYVdsONUolf/BwVcm+15eqcdAj15h4Qe9MMFAwwT4= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= From c3ce2f97bf98b2d49aac244c10cc25a07aada578 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Nov 2024 04:44:49 +0000 Subject: [PATCH 038/198] chore(deps): bump github.com/charmbracelet/bubbletea from 1.2.1 to 1.2.2 (#712) Bumps [github.com/charmbracelet/bubbletea](https://github.com/charmbracelet/bubbletea) from 1.2.1 to 1.2.2. - [Release notes](https://github.com/charmbracelet/bubbletea/releases) - [Changelog](https://github.com/charmbracelet/bubbletea/blob/main/.goreleaser.yml) - [Commits](https://github.com/charmbracelet/bubbletea/compare/v1.2.1...v1.2.2) --- updated-dependencies: - dependency-name: github.com/charmbracelet/bubbletea dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index b9de049..56c186b 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/alecthomas/kong v1.4.0 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 - github.com/charmbracelet/bubbletea v1.2.1 + github.com/charmbracelet/bubbletea v1.2.2 github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/huh v0.6.0 github.com/charmbracelet/lipgloss v1.0.0 @@ -45,8 +45,8 @@ require ( github.com/yuin/goldmark-emoji v1.0.4 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/net v0.27.0 // indirect - golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.26.0 // indirect + golang.org/x/sync v0.9.0 // indirect + golang.org/x/sys v0.27.0 // indirect golang.org/x/term v0.22.0 // indirect golang.org/x/text v0.18.0 // indirect ) diff --git a/go.sum b/go.sum index 2f23d09..391c012 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/catppuccin/go v0.2.0 h1:ktBeIrIP42b/8FGiScP9sgrWOss3lw0Z5SktRoithGA= github.com/catppuccin/go v0.2.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc= github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE= github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU= -github.com/charmbracelet/bubbletea v1.2.1 h1:J041h57zculJKEKf/O2pS4edXGIz+V0YvojvfGXePIk= -github.com/charmbracelet/bubbletea v1.2.1/go.mod h1:viLoDL7hG4njLJSKU2gw7kB3LSEmWsrM80rO1dBJWBI= +github.com/charmbracelet/bubbletea v1.2.2 h1:EMz//Ky/aFS2uLcKqpCst5UOE6z5CFDGRsUpyXz0chs= +github.com/charmbracelet/bubbletea v1.2.2/go.mod h1:Qr6fVQw+wX7JkWWkVyXYk/ZUQ92a6XNekLXa3rR18MM= github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= github.com/charmbracelet/huh v0.6.0 h1:mZM8VvZGuE0hoDXq6XLxRtgfWyTI3b2jZNKh0xWmax8= @@ -100,12 +100,12 @@ golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0J golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= +golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= -golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= From 93da22d656e810ecd6ceb0dfe0375fdab8748a38 Mon Sep 17 00:00:00 2001 From: Dieter Eickstaedt Date: Fri, 15 Nov 2024 17:50:37 +0100 Subject: [PATCH 039/198] feat(table): adds --return-column (#415) * feat: Adding Return Column to table command Consider a table of ID Name Description 1 Task1 Task description It would be good to select the row but retrieve the ID for example for further processing like 'task 1 delete' when first row was selected * feat: Return Column boundary check fixed * Update table/options.go --------- Co-authored-by: Carlos Alexandro Becker --- table/command.go | 10 ++++++++-- table/options.go | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/table/command.go b/table/command.go index 1e08faf..913e262 100644 --- a/table/command.go +++ b/table/command.go @@ -121,8 +121,14 @@ func (o Options) Run() error { m := tm.(model) - if err = writer.Write([]string(m.selected)); err != nil { - return fmt.Errorf("failed to write selected row: %w", err) + if o.ReturnColumn > 0 && o.ReturnColumn <= len(m.selected) { + if err = writer.Write([]string{m.selected[o.ReturnColumn-1]}); err != nil { + return fmt.Errorf("failed to write col %d of selected row: %w", o.ReturnColumn, err) + } + } else { + if err = writer.Write([]string(m.selected)); err != nil { + return fmt.Errorf("failed to write selected row: %w", err) + } } writer.Flush() diff --git a/table/options.go b/table/options.go index a7a3f29..fcfa579 100644 --- a/table/options.go +++ b/table/options.go @@ -16,4 +16,5 @@ type Options struct { CellStyle style.Styles `embed:"" prefix:"cell." envprefix:"GUM_TABLE_CELL_"` HeaderStyle style.Styles `embed:"" prefix:"header." envprefix:"GUM_TABLE_HEADER_"` SelectedStyle style.Styles `embed:"" prefix:"selected." set:"defaultForeground=212" envprefix:"GUM_TABLE_SELECTED_"` + ReturnColumn int `short:"r" help:"Which column number should be returned instead of whole row as string. Default=0 returns whole Row" default:"0"` } From 19e79b11e46387e9d1dd839778a4ffe2ad14afcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Pritchett=20=E2=9A=A1?= Date: Fri, 15 Nov 2024 11:57:27 -0600 Subject: [PATCH 040/198] fix(confirm): `--timeout` was being ignored (#697) * fix(confirm) Options.Timeout was ignored, now works as documented * Streamlines command.go per PR feedback --- confirm/command.go | 14 ++++++++++- confirm/command_test.go | 54 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 confirm/command_test.go diff --git a/confirm/command.go b/confirm/command.go index 30fd51d..87f6065 100644 --- a/confirm/command.go +++ b/confirm/command.go @@ -1,6 +1,7 @@ package confirm import ( + "errors" "fmt" "os" @@ -26,12 +27,15 @@ func (o Options) Run() error { Value(&choice), ), ). + WithTimeout(o.Timeout). WithTheme(theme). WithShowHelp(o.ShowHelp). Run() if err != nil { - return fmt.Errorf("unable to run confirm: %w", err) + if !o.errIsValidTimeout(err) { + return fmt.Errorf("unable to run confirm: %w", err) + } } if !choice { @@ -40,3 +44,11 @@ func (o Options) Run() error { return nil } + +// errIsValidTimeout returns false unless 1) the user has specified a nonzero timeout and 2) the error is a huh.ErrTimeout. +func (o Options) errIsValidTimeout(err error) bool { + errWasTimeout := errors.Is(err, huh.ErrTimeout) + timeoutsExpected := o.Timeout > 0 + + return errWasTimeout && timeoutsExpected +} diff --git a/confirm/command_test.go b/confirm/command_test.go new file mode 100644 index 0000000..314a3b6 --- /dev/null +++ b/confirm/command_test.go @@ -0,0 +1,54 @@ +package confirm + +import ( + "fmt" + "github.com/charmbracelet/huh" + "testing" + "time" +) + +func TestOptions_errIsValidTimeout(t *testing.T) { + type testCase struct { + Description string + GivenTimeout time.Duration + GivenError error + ExpectedResult bool + } + + cases := []testCase{ + { + Description: "timeout is positive, err is a timeout", + GivenTimeout: time.Second, + GivenError: huh.ErrTimeout, + ExpectedResult: true, + }, + { + Description: "timeout is zero, err is a timeout", + GivenTimeout: 0, + GivenError: huh.ErrTimeout, + ExpectedResult: false, + }, + { + Description: "timeout is positive, err is not a timeout", + GivenTimeout: 1, + GivenError: fmt.Errorf("i'm not a timeout"), + ExpectedResult: false, + }, + { + Description: "timeout is zero, err is not a timeout", + GivenTimeout: 0, + GivenError: fmt.Errorf("i'm not a timeout"), + ExpectedResult: false, + }, + } + + for _, testCase := range cases { + t.Run(testCase.Description, func(t *testing.T) { + sut := Options{Timeout: testCase.GivenTimeout} + actualResult := sut.errIsValidTimeout(testCase.GivenError) + if actualResult != testCase.ExpectedResult { + t.Errorf("got: %v, want: %v", actualResult, testCase.ExpectedResult) + } + }) + } +} From 6a05246f5339d5671caedef93f21901ded174b0b Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Fri, 15 Nov 2024 13:37:16 -0500 Subject: [PATCH 041/198] fix: catch huh timeout error (#632) Huh returns a `ErrTimeout` on timeout error and we need to catch that. Fixes: https://github.com/charmbracelet/gum/pull/618 --- choose/command.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/choose/command.go b/choose/command.go index 8fe7773..f96b1be 100644 --- a/choose/command.go +++ b/choose/command.go @@ -77,7 +77,7 @@ func (o Options) Run() error { WithShowHelp(o.ShowHelp). WithTheme(theme). Run() - if err != nil { + if err != nil && !errors.Is(err, huh.ErrTimeout) { return err } if len(choices) > 0 { @@ -102,7 +102,7 @@ func (o Options) Run() error { WithTheme(theme). WithShowHelp(o.ShowHelp). Run() - if err != nil { + if err != nil && !errors.Is(err, huh.ErrTimeout) { return err } From f8c466bf3b122c9a6d333d5f42e24212d0cd09d2 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 15 Nov 2024 15:35:32 -0300 Subject: [PATCH 042/198] fix(confirm): improve timeout handling Signed-off-by: Carlos Alexandro Becker --- confirm/command.go | 11 +-------- confirm/command_test.go | 54 ----------------------------------------- 2 files changed, 1 insertion(+), 64 deletions(-) delete mode 100644 confirm/command_test.go diff --git a/confirm/command.go b/confirm/command.go index 87f6065..9985108 100644 --- a/confirm/command.go +++ b/confirm/command.go @@ -31,9 +31,8 @@ func (o Options) Run() error { WithTheme(theme). WithShowHelp(o.ShowHelp). Run() - if err != nil { - if !o.errIsValidTimeout(err) { + if o.Timeout > 0 && errors.Is(err, huh.ErrTimeout) { return fmt.Errorf("unable to run confirm: %w", err) } } @@ -44,11 +43,3 @@ func (o Options) Run() error { return nil } - -// errIsValidTimeout returns false unless 1) the user has specified a nonzero timeout and 2) the error is a huh.ErrTimeout. -func (o Options) errIsValidTimeout(err error) bool { - errWasTimeout := errors.Is(err, huh.ErrTimeout) - timeoutsExpected := o.Timeout > 0 - - return errWasTimeout && timeoutsExpected -} diff --git a/confirm/command_test.go b/confirm/command_test.go deleted file mode 100644 index 314a3b6..0000000 --- a/confirm/command_test.go +++ /dev/null @@ -1,54 +0,0 @@ -package confirm - -import ( - "fmt" - "github.com/charmbracelet/huh" - "testing" - "time" -) - -func TestOptions_errIsValidTimeout(t *testing.T) { - type testCase struct { - Description string - GivenTimeout time.Duration - GivenError error - ExpectedResult bool - } - - cases := []testCase{ - { - Description: "timeout is positive, err is a timeout", - GivenTimeout: time.Second, - GivenError: huh.ErrTimeout, - ExpectedResult: true, - }, - { - Description: "timeout is zero, err is a timeout", - GivenTimeout: 0, - GivenError: huh.ErrTimeout, - ExpectedResult: false, - }, - { - Description: "timeout is positive, err is not a timeout", - GivenTimeout: 1, - GivenError: fmt.Errorf("i'm not a timeout"), - ExpectedResult: false, - }, - { - Description: "timeout is zero, err is not a timeout", - GivenTimeout: 0, - GivenError: fmt.Errorf("i'm not a timeout"), - ExpectedResult: false, - }, - } - - for _, testCase := range cases { - t.Run(testCase.Description, func(t *testing.T) { - sut := Options{Timeout: testCase.GivenTimeout} - actualResult := sut.errIsValidTimeout(testCase.GivenError) - if actualResult != testCase.ExpectedResult { - t.Errorf("got: %v, want: %v", actualResult, testCase.ExpectedResult) - } - }) - } -} From 7bdd189616935c155e64403b629d2afa05277614 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Fri, 15 Nov 2024 13:53:27 -0500 Subject: [PATCH 043/198] fix(spin): indenting lines when command is piped (#636) We don't need to check for isatty, always store the output to the designated buffer. Fixes: https://github.com/charmbracelet/gum/issues/607 --- spin/spin.go | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/spin/spin.go b/spin/spin.go index db63fa4..26c933f 100644 --- a/spin/spin.go +++ b/spin/spin.go @@ -16,14 +16,12 @@ package spin import ( "io" - "os" "os/exec" "strings" "time" "github.com/charmbracelet/gum/internal/exit" "github.com/charmbracelet/gum/timeout" - "github.com/charmbracelet/x/term" "github.com/charmbracelet/bubbles/spinner" tea "github.com/charmbracelet/bubbletea" @@ -65,22 +63,12 @@ func commandStart(command []string) tea.Cmd { if len(command) > 1 { args = command[1:] } + cmd := exec.Command(command[0], args...) //nolint:gosec - - if term.IsTerminal(os.Stdout.Fd()) { - stdout := io.MultiWriter(&bothbuf, &errbuf) - stderr := io.MultiWriter(&bothbuf, &outbuf) - - cmd.Stdout = stdout - cmd.Stderr = stderr - } else { - cmd.Stdout = os.Stdout - } - + cmd.Stdout = io.MultiWriter(&bothbuf, &outbuf) + cmd.Stderr = io.MultiWriter(&bothbuf, &errbuf) _ = cmd.Run() - status := cmd.ProcessState.ExitCode() - if status == -1 { status = 1 } From 6ad8882990183230ecabe587cda211de617eb0f0 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 18 Nov 2024 09:07:19 -0300 Subject: [PATCH 044/198] fix(table): only set height if > 0 (#716) closes #685 closes #660 --- table/command.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/table/command.go b/table/command.go index 913e262..98b5fdc 100644 --- a/table/command.go +++ b/table/command.go @@ -102,13 +102,16 @@ func (o Options) Run() error { return nil } - table := table.New( + opts := []table.Option{ table.WithColumns(columns), table.WithFocused(true), - table.WithHeight(o.Height), table.WithRows(rows), table.WithStyles(styles), - ) + } + if o.Height > 0 { + opts = append(opts, table.WithHeight(o.Height)) + } + table := table.New(opts...) tm, err := tea.NewProgram(model{table: table}, tea.WithOutput(os.Stderr)).Run() if err != nil { From 60a4b3bf93f7cff0c8e6640b29640c609a44fbea Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 18 Nov 2024 09:07:48 -0300 Subject: [PATCH 045/198] feat(filepicker): show permissions and size (#717) closes #495 --- file/command.go | 3 ++- file/options.go | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/file/command.go b/file/command.go index f60ed29..7d02b6e 100644 --- a/file/command.go +++ b/file/command.go @@ -46,6 +46,8 @@ func (o Options) Run() error { FileAllowed(o.File). Height(o.Height). ShowHidden(o.All). + ShowSize(o.Size). + ShowPermissions(o.Permissions). Value(&path), ), ). @@ -53,7 +55,6 @@ func (o Options) Run() error { WithKeyMap(keymap). WithTheme(theme). Run() - if err != nil { return err } diff --git a/file/options.go b/file/options.go index 5d4593d..072bd34 100644 --- a/file/options.go +++ b/file/options.go @@ -11,11 +11,13 @@ type Options struct { // Path is the path to the folder / directory to begin traversing. Path string `arg:"" optional:"" name:"path" help:"The path to the folder to begin traversing" env:"GUM_FILE_PATH"` // Cursor is the character to display in front of the current selected items. - Cursor string `short:"c" help:"The cursor character" default:">" env:"GUM_FILE_CURSOR"` - All bool `short:"a" help:"Show hidden and 'dot' files" default:"false" env:"GUM_FILE_ALL"` - File bool `help:"Allow files selection" default:"true" env:"GUM_FILE_FILE"` - Directory bool `help:"Allow directories selection" default:"false" env:"GUM_FILE_DIRECTORY"` - ShowHelp bool `help:"Show help key binds" negatable:"" default:"true" env:"GUM_FILE_SHOW_HELP"` + Cursor string `short:"c" help:"The cursor character" default:">" env:"GUM_FILE_CURSOR"` + All bool `short:"a" help:"Show hidden and 'dot' files" default:"false" env:"GUM_FILE_ALL"` + Permissions bool `short:"p" help:"Show file permissions" default:"true" negatable:"" env:"GUM_FILE_PERMISSION"` + Size bool `short:"s" help:"Show file size" default:"true" negatable:"" env:"GUM_FILE_SIZE"` + File bool `help:"Allow files selection" default:"true" env:"GUM_FILE_FILE"` + Directory bool `help:"Allow directories selection" default:"false" env:"GUM_FILE_DIRECTORY"` + ShowHelp bool `help:"Show help key binds" negatable:"" default:"true" env:"GUM_FILE_SHOW_HELP"` Height int `help:"Maximum number of files to display" default:"0" env:"GUM_FILE_HEIGHT"` CursorStyle style.Styles `embed:"" prefix:"cursor." help:"The cursor style" set:"defaultForeground=212" envprefix:"GUM_FILE_CURSOR_"` From 3cec9b7b9a5395b6d41620789b2197cb76330062 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 18 Nov 2024 10:00:10 -0300 Subject: [PATCH 046/198] fix(filter): panic if no matches closes #715 Signed-off-by: Carlos Alexandro Becker --- filter/filter.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/filter/filter.go b/filter/filter.go index 3ed1e78..6b51e7c 100644 --- a/filter/filter.go +++ b/filter/filter.go @@ -255,6 +255,9 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } func (m *model) CursorUp() { + if len(m.matches) == 0 { + return + } if m.reverse { //nolint:nestif m.cursor = (m.cursor + 1) % len(m.matches) if len(m.matches)-m.cursor <= m.viewport.YOffset { @@ -275,6 +278,9 @@ func (m *model) CursorUp() { } func (m *model) CursorDown() { + if len(m.matches) == 0 { + return + } if m.reverse { //nolint:nestif m.cursor = (m.cursor - 1 + len(m.matches)) % len(m.matches) if len(m.matches)-m.cursor > m.viewport.Height+m.viewport.YOffset { From c868aa1c6ce85e1a3c62ba47ca96e838a8ac3e34 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 18 Nov 2024 10:49:15 -0300 Subject: [PATCH 047/198] fix(confirm,choose,file,input): timeout handling (#718) * fix(confirm,choose,file,input): timeout handling - some fields were not actually using the `--timeout` value - some fields had different behavior when a timeout did occur. On this matter, it seems to me the best way forward is to specifically say it timed out, and after how long - added exit status 124 (copied from `timeout` from coreutils) (fixes #684) Signed-off-by: Carlos Alexandro Becker * Update main.go Co-authored-by: Ayman Bagabas * Update internal/exit/exit.go Co-authored-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com> * fix: improve Signed-off-by: Carlos Alexandro Becker * fix: stderr --------- Signed-off-by: Carlos Alexandro Becker Co-authored-by: Ayman Bagabas Co-authored-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com> --- choose/command.go | 11 +++++++---- confirm/command.go | 7 ++----- file/command.go | 5 +++-- input/command.go | 4 +++- internal/exit/exit.go | 23 ++++++++++++++++++++--- main.go | 8 ++++++-- 6 files changed, 41 insertions(+), 17 deletions(-) diff --git a/choose/command.go b/choose/command.go index f96b1be..d4b1c42 100644 --- a/choose/command.go +++ b/choose/command.go @@ -11,6 +11,7 @@ import ( "github.com/charmbracelet/x/ansi" "github.com/charmbracelet/x/term" + "github.com/charmbracelet/gum/internal/exit" "github.com/charmbracelet/gum/internal/stdin" ) @@ -76,9 +77,10 @@ func (o Options) Run() error { WithWidth(width). WithShowHelp(o.ShowHelp). WithTheme(theme). + WithTimeout(o.Timeout). Run() - if err != nil && !errors.Is(err, huh.ErrTimeout) { - return err + if err != nil { + return exit.Handle(err, o.Timeout) } if len(choices) > 0 { s := strings.Join(choices, "\n") @@ -100,10 +102,11 @@ func (o Options) Run() error { ). WithWidth(width). WithTheme(theme). + WithTimeout(o.Timeout). WithShowHelp(o.ShowHelp). Run() - if err != nil && !errors.Is(err, huh.ErrTimeout) { - return err + if err != nil { + return exit.Handle(err, o.Timeout) } if term.IsTerminal(os.Stdout.Fd()) { diff --git a/confirm/command.go b/confirm/command.go index 9985108..3653502 100644 --- a/confirm/command.go +++ b/confirm/command.go @@ -1,10 +1,9 @@ package confirm import ( - "errors" - "fmt" "os" + "github.com/charmbracelet/gum/internal/exit" "github.com/charmbracelet/huh" ) @@ -32,9 +31,7 @@ func (o Options) Run() error { WithShowHelp(o.ShowHelp). Run() if err != nil { - if o.Timeout > 0 && errors.Is(err, huh.ErrTimeout) { - return fmt.Errorf("unable to run confirm: %w", err) - } + return exit.Handle(err, o.Timeout) } if !choice { diff --git a/file/command.go b/file/command.go index 7d02b6e..9d8b50f 100644 --- a/file/command.go +++ b/file/command.go @@ -5,6 +5,7 @@ import ( "fmt" "path/filepath" + "github.com/charmbracelet/gum/internal/exit" "github.com/charmbracelet/huh" "github.com/charmbracelet/lipgloss" ) @@ -51,14 +52,14 @@ func (o Options) Run() error { Value(&path), ), ). + WithTimeout(o.Timeout). WithShowHelp(o.ShowHelp). WithKeyMap(keymap). WithTheme(theme). Run() if err != nil { - return err + return exit.Handle(err, o.Timeout) } - fmt.Println(path) return nil } diff --git a/input/command.go b/input/command.go index b35ce20..d35515e 100644 --- a/input/command.go +++ b/input/command.go @@ -9,6 +9,7 @@ import ( "github.com/charmbracelet/huh" "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/gum/internal/exit" "github.com/charmbracelet/gum/internal/stdin" ) @@ -53,11 +54,12 @@ func (o Options) Run() error { WithWidth(o.Width). WithTheme(theme). WithKeyMap(keymap). + WithTimeout(o.Timeout). WithShowHelp(o.ShowHelp). WithProgramOptions(tea.WithOutput(os.Stderr)). Run() if err != nil { - return err + return exit.Handle(err, o.Timeout) } fmt.Println(value) diff --git a/internal/exit/exit.go b/internal/exit/exit.go index ff3a2b9..e79d7c2 100644 --- a/internal/exit/exit.go +++ b/internal/exit/exit.go @@ -1,9 +1,26 @@ package exit -import "fmt" +import ( + "errors" + "fmt" + "time" + + "github.com/charmbracelet/huh" +) + +// StatusTimeout is the exit code for timed out commands. +const StatusTimeout = 124 // StatusAborted is the exit code for aborted commands. const StatusAborted = 130 -// ErrAborted is the error to return when a gum command is aborted by Ctrl + C. -var ErrAborted = fmt.Errorf("aborted") +// ErrAborted is the error to return when a gum command is aborted by Ctrl+C. +var ErrAborted = huh.ErrUserAborted + +// Handle handles the error. +func Handle(err error, d time.Duration) error { + if errors.Is(err, huh.ErrTimeout) { + return fmt.Errorf("%w after %s", huh.ErrTimeout, d) + } + return err +} diff --git a/main.go b/main.go index b8f3407..301baef 100644 --- a/main.go +++ b/main.go @@ -73,10 +73,14 @@ func main() { }, ) if err := ctx.Run(); err != nil { - if errors.Is(err, exit.ErrAborted) || errors.Is(err, huh.ErrUserAborted) { + if errors.Is(err, huh.ErrTimeout) { + fmt.Fprintln(os.Stderr, err) + os.Exit(exit.StatusTimeout) + } + if errors.Is(err, huh.ErrUserAborted) { os.Exit(exit.StatusAborted) } - fmt.Println(err) + fmt.Fprintln(os.Stderr, err) os.Exit(1) } } From 1ffe8b7e70ee970c1f3efe09f79c4b7e7662c95a Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 18 Nov 2024 14:02:55 -0300 Subject: [PATCH 048/198] feat(log): support setting minimum log level with GUM_LOG_LEVEL (#723) closes #490 --- log/command.go | 7 +++++++ log/options.go | 2 ++ 2 files changed, 9 insertions(+) diff --git a/log/command.go b/log/command.go index 7ea959e..aff18cf 100644 --- a/log/command.go +++ b/log/command.go @@ -28,6 +28,13 @@ func (o Options) Run() error { l.SetPrefix(o.Prefix) l.SetLevel(-math.MaxInt32) // log all levels l.SetReportTimestamp(o.Time != "") + if o.MinLevel != "" { + lvl, err := log.ParseLevel(o.MinLevel) + if err != nil { + return err + } + l.SetLevel(lvl) + } timeFormats := map[string]string{ "layout": time.Layout, diff --git a/log/options.go b/log/options.go index 9a19f36..73fbcec 100644 --- a/log/options.go +++ b/log/options.go @@ -16,6 +16,8 @@ type Options struct { Structured bool `short:"s" help:"Use structured logging" xor:"format,structured"` Time string `short:"t" help:"The time format to use (kitchen, layout, ansic, rfc822, etc...)" default:""` + MinLevel string `help:"Minimal level to show" default:"" env:"GUM_LOG_LEVEL"` + LevelStyle style.Styles `embed:"" prefix:"level." help:"The style of the level being used" set:"defaultBold=true" envprefix:"GUM_LOG_LEVEL_"` //nolint:staticcheck TimeStyle style.Styles `embed:"" prefix:"time." help:"The style of the time" envprefix:"GUM_LOG_TIME_"` PrefixStyle style.Styles `embed:"" prefix:"prefix." help:"The style of the prefix" set:"defaultBold=true" set:"defaultFaint=true" envprefix:"GUM_LOG_PREFIX_"` //nolint:staticcheck From 098d09a270d703c60804a9bda678d9bae1f1005b Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 18 Nov 2024 17:10:06 -0300 Subject: [PATCH 049/198] fix(choose,confirm,file,filter,input,pager,spin): timeout default unit (#724) Change it `0s` instead of `0`. closes #402 --- choose/options.go | 2 +- confirm/options.go | 2 +- file/options.go | 2 +- filter/options.go | 2 +- input/options.go | 2 +- pager/options.go | 2 +- spin/options.go | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/choose/options.go b/choose/options.go index e9c393c..b02b05d 100644 --- a/choose/options.go +++ b/choose/options.go @@ -25,5 +25,5 @@ type Options struct { HeaderStyle style.Styles `embed:"" prefix:"header." set:"defaultForeground=99" envprefix:"GUM_CHOOSE_HEADER_"` ItemStyle style.Styles `embed:"" prefix:"item." hidden:"" envprefix:"GUM_CHOOSE_ITEM_"` SelectedItemStyle style.Styles `embed:"" prefix:"selected." set:"defaultForeground=212" envprefix:"GUM_CHOOSE_SELECTED_"` - Timeout time.Duration `help:"Timeout until choose returns selected element" default:"0" env:"GUM_CCHOOSE_TIMEOUT"` // including timeout command options [Timeout,...] + Timeout time.Duration `help:"Timeout until choose returns selected element" default:"0s" env:"GUM_CCHOOSE_TIMEOUT"` // including timeout command options [Timeout,...] } diff --git a/confirm/options.go b/confirm/options.go index f604816..7337711 100644 --- a/confirm/options.go +++ b/confirm/options.go @@ -19,5 +19,5 @@ type Options struct { //nolint:staticcheck UnselectedStyle style.Styles `embed:"" prefix:"unselected." help:"The style of the unselected action" set:"defaultBackground=235" set:"defaultForeground=254" set:"defaultPadding=0 3" set:"defaultMargin=0 1" envprefix:"GUM_CONFIRM_UNSELECTED_"` ShowHelp bool `help:"Show help key binds" negatable:"" default:"true" env:"GUM_CONFIRM_SHOW_HELP"` - Timeout time.Duration `help:"Timeout until confirm returns selected value or default if provided" default:"0" env:"GUM_CONFIRM_TIMEOUT"` + Timeout time.Duration `help:"Timeout until confirm returns selected value or default if provided" default:"0s" env:"GUM_CONFIRM_TIMEOUT"` } diff --git a/file/options.go b/file/options.go index 072bd34..0f8f9af 100644 --- a/file/options.go +++ b/file/options.go @@ -29,5 +29,5 @@ type Options struct { SelectedStyle style.Styles `embed:"" prefix:"selected." help:"The style to use for the selected item" set:"defaultBold=true" set:"defaultForeground=212" envprefix:"GUM_FILE_SELECTED_"` //nolint:staticcheck FileSizeStyle style.Styles `embed:"" prefix:"file-size." help:"The style to use for file sizes" set:"defaultWidth=8" set:"defaultAlign=right" set:"defaultForeground=240" envprefix:"GUM_FILE_FILE_SIZE_"` - Timeout time.Duration `help:"Timeout until command aborts without a selection" default:"0" env:"GUM_FILE_TIMEOUT"` + Timeout time.Duration `help:"Timeout until command aborts without a selection" default:"0s" env:"GUM_FILE_TIMEOUT"` } diff --git a/filter/options.go b/filter/options.go index f4d57cb..1490c49 100644 --- a/filter/options.go +++ b/filter/options.go @@ -35,5 +35,5 @@ type Options struct { Reverse bool `help:"Display from the bottom of the screen" env:"GUM_FILTER_REVERSE"` Fuzzy bool `help:"Enable fuzzy matching" default:"true" env:"GUM_FILTER_FUZZY" negatable:""` Sort bool `help:"Sort the results" default:"true" env:"GUM_FILTER_SORT" negatable:""` - Timeout time.Duration `help:"Timeout until filter command aborts" default:"0" env:"GUM_FILTER_TIMEOUT"` + Timeout time.Duration `help:"Timeout until filter command aborts" default:"0s" env:"GUM_FILTER_TIMEOUT"` } diff --git a/input/options.go b/input/options.go index 2ef8b1a..a89b0e0 100644 --- a/input/options.go +++ b/input/options.go @@ -21,5 +21,5 @@ type Options struct { ShowHelp bool `help:"Show help keybinds" default:"true" negatable:"true" env:"GUM_INPUT_SHOW_HELP"` Header string `help:"Header value" default:"" env:"GUM_INPUT_HEADER"` HeaderStyle style.Styles `embed:"" prefix:"header." set:"defaultForeground=240" envprefix:"GUM_INPUT_HEADER_"` - Timeout time.Duration `help:"Timeout until input aborts" default:"0" env:"GUM_INPUT_TIMEOUT"` + Timeout time.Duration `help:"Timeout until input aborts" default:"0s" env:"GUM_INPUT_TIMEOUT"` } diff --git a/pager/options.go b/pager/options.go index f257cb0..15e479a 100644 --- a/pager/options.go +++ b/pager/options.go @@ -17,5 +17,5 @@ type Options struct { SoftWrap bool `help:"Soft wrap lines" default:"false"` MatchStyle style.Styles `embed:"" prefix:"match." help:"Style the matched text" set:"defaultForeground=212" set:"defaultBold=true" envprefix:"GUM_PAGER_MATCH_"` //nolint:staticcheck MatchHighlightStyle style.Styles `embed:"" prefix:"match-highlight." help:"Style the matched highlight text" set:"defaultForeground=235" set:"defaultBackground=225" set:"defaultBold=true" envprefix:"GUM_PAGER_MATCH_HIGH_"` //nolint:staticcheck - Timeout time.Duration `help:"Timeout until command exits" default:"0" env:"GUM_PAGER_TIMEOUT"` + Timeout time.Duration `help:"Timeout until command exits" default:"0s" env:"GUM_PAGER_TIMEOUT"` } diff --git a/spin/options.go b/spin/options.go index 542ff2b..e0b3208 100644 --- a/spin/options.go +++ b/spin/options.go @@ -17,5 +17,5 @@ type Options struct { Title string `help:"Text to display to user while spinning" default:"Loading..." env:"GUM_SPIN_TITLE"` TitleStyle style.Styles `embed:"" prefix:"title." envprefix:"GUM_SPIN_TITLE_"` Align string `help:"Alignment of spinner with regard to the title" short:"a" type:"align" enum:"left,right" default:"left" env:"GUM_SPIN_ALIGN"` - Timeout time.Duration `help:"Timeout until spin command aborts" default:"0" env:"GUM_SPIN_TIMEOUT"` + Timeout time.Duration `help:"Timeout until spin command aborts" default:"0s" env:"GUM_SPIN_TIMEOUT"` } From 06bdaba08f5f6b2cf4d8d1c6fe5e6a4122211163 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Nov 2024 04:37:21 +0000 Subject: [PATCH 050/198] chore(deps): bump github.com/charmbracelet/bubbletea from 1.2.2 to 1.2.3 (#726) Bumps [github.com/charmbracelet/bubbletea](https://github.com/charmbracelet/bubbletea) from 1.2.2 to 1.2.3. - [Release notes](https://github.com/charmbracelet/bubbletea/releases) - [Changelog](https://github.com/charmbracelet/bubbletea/blob/main/.goreleaser.yml) - [Commits](https://github.com/charmbracelet/bubbletea/compare/v1.2.2...v1.2.3) --- updated-dependencies: - dependency-name: github.com/charmbracelet/bubbletea dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 56c186b..8cc0bc8 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/alecthomas/kong v1.4.0 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 - github.com/charmbracelet/bubbletea v1.2.2 + github.com/charmbracelet/bubbletea v1.2.3 github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/huh v0.6.0 github.com/charmbracelet/lipgloss v1.0.0 diff --git a/go.sum b/go.sum index 391c012..0815cb3 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/catppuccin/go v0.2.0 h1:ktBeIrIP42b/8FGiScP9sgrWOss3lw0Z5SktRoithGA= github.com/catppuccin/go v0.2.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc= github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE= github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU= -github.com/charmbracelet/bubbletea v1.2.2 h1:EMz//Ky/aFS2uLcKqpCst5UOE6z5CFDGRsUpyXz0chs= -github.com/charmbracelet/bubbletea v1.2.2/go.mod h1:Qr6fVQw+wX7JkWWkVyXYk/ZUQ92a6XNekLXa3rR18MM= +github.com/charmbracelet/bubbletea v1.2.3 h1:d9MdMsANIYZB5pE1KkRqaUV6GfsiWm+/9z4fTuGVm9I= +github.com/charmbracelet/bubbletea v1.2.3/go.mod h1:Qr6fVQw+wX7JkWWkVyXYk/ZUQ92a6XNekLXa3rR18MM= github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= github.com/charmbracelet/huh v0.6.0 h1:mZM8VvZGuE0hoDXq6XLxRtgfWyTI3b2jZNKh0xWmax8= From 8ed2ca5e0d770ca76b1b74fd9d60ab80cee27c7c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 04:56:03 +0000 Subject: [PATCH 051/198] chore(deps): bump github.com/charmbracelet/x/ansi from 0.4.5 to 0.5.0 (#728) Bumps [github.com/charmbracelet/x/ansi](https://github.com/charmbracelet/x) from 0.4.5 to 0.5.0. - [Release notes](https://github.com/charmbracelet/x/releases) - [Commits](https://github.com/charmbracelet/x/compare/ansi/v0.4.5...ansi/v0.5.0) --- updated-dependencies: - dependency-name: github.com/charmbracelet/x/ansi dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 8cc0bc8..1b0c97e 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/charmbracelet/huh v0.6.0 github.com/charmbracelet/lipgloss v1.0.0 github.com/charmbracelet/log v0.4.0 - github.com/charmbracelet/x/ansi v0.4.5 + github.com/charmbracelet/x/ansi v0.5.0 github.com/charmbracelet/x/term v0.2.1 github.com/muesli/reflow v0.3.0 github.com/muesli/roff v0.1.0 diff --git a/go.sum b/go.sum index 0815cb3..c4a6d26 100644 --- a/go.sum +++ b/go.sum @@ -32,8 +32,8 @@ github.com/charmbracelet/lipgloss v1.0.0 h1:O7VkGDvqEdGi93X+DeqsQ7PKHDgtQfF8j8/O github.com/charmbracelet/lipgloss v1.0.0/go.mod h1:U5fy9Z+C38obMs+T+tJqst9VGzlOYGj4ri9reL3qUlo= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= -github.com/charmbracelet/x/ansi v0.4.5 h1:LqK4vwBNaXw2AyGIICa5/29Sbdq58GbGdFngSexTdRM= -github.com/charmbracelet/x/ansi v0.4.5/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= +github.com/charmbracelet/x/ansi v0.5.0 h1:o94cKkWJRaiNQYbfz5WOLrbg9hULaryyKvWm+oLX7js= +github.com/charmbracelet/x/ansi v0.5.0/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 h1:qko3AQ4gK1MTS/de7F5hPGx6/k1u0w4TeYmBFwzYVP4= From 1156c33ad5f94f5804983ad5463fd9763c04e928 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Nov 2024 04:19:11 +0000 Subject: [PATCH 052/198] chore(deps): bump github.com/charmbracelet/x/ansi from 0.5.0 to 0.5.2 (#729) Bumps [github.com/charmbracelet/x/ansi](https://github.com/charmbracelet/x) from 0.5.0 to 0.5.2. - [Release notes](https://github.com/charmbracelet/x/releases) - [Commits](https://github.com/charmbracelet/x/compare/ansi/v0.5.0...ansi/v0.5.2) --- updated-dependencies: - dependency-name: github.com/charmbracelet/x/ansi dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 1b0c97e..6f7648b 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/charmbracelet/huh v0.6.0 github.com/charmbracelet/lipgloss v1.0.0 github.com/charmbracelet/log v0.4.0 - github.com/charmbracelet/x/ansi v0.5.0 + github.com/charmbracelet/x/ansi v0.5.2 github.com/charmbracelet/x/term v0.2.1 github.com/muesli/reflow v0.3.0 github.com/muesli/roff v0.1.0 diff --git a/go.sum b/go.sum index c4a6d26..0cfaa1b 100644 --- a/go.sum +++ b/go.sum @@ -32,8 +32,8 @@ github.com/charmbracelet/lipgloss v1.0.0 h1:O7VkGDvqEdGi93X+DeqsQ7PKHDgtQfF8j8/O github.com/charmbracelet/lipgloss v1.0.0/go.mod h1:U5fy9Z+C38obMs+T+tJqst9VGzlOYGj4ri9reL3qUlo= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= -github.com/charmbracelet/x/ansi v0.5.0 h1:o94cKkWJRaiNQYbfz5WOLrbg9hULaryyKvWm+oLX7js= -github.com/charmbracelet/x/ansi v0.5.0/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= +github.com/charmbracelet/x/ansi v0.5.2 h1:dEa1x2qdOZXD/6439s+wF7xjV+kZLu/iN00GuXXrU9E= +github.com/charmbracelet/x/ansi v0.5.2/go.mod h1:KBUFw1la39nl0dLl10l5ORDAqGXaeurTQmwyyVKse/Q= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 h1:qko3AQ4gK1MTS/de7F5hPGx6/k1u0w4TeYmBFwzYVP4= From e3ba400d6d6748091dcb7911d03ff75bf0c22167 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Nov 2024 04:38:37 +0000 Subject: [PATCH 053/198] chore(deps): bump github.com/charmbracelet/bubbletea from 1.2.3 to 1.2.4 (#731) Bumps [github.com/charmbracelet/bubbletea](https://github.com/charmbracelet/bubbletea) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/charmbracelet/bubbletea/releases) - [Changelog](https://github.com/charmbracelet/bubbletea/blob/main/.goreleaser.yml) - [Commits](https://github.com/charmbracelet/bubbletea/compare/v1.2.3...v1.2.4) --- updated-dependencies: - dependency-name: github.com/charmbracelet/bubbletea dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6f7648b..e106803 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/alecthomas/kong v1.4.0 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 - github.com/charmbracelet/bubbletea v1.2.3 + github.com/charmbracelet/bubbletea v1.2.4 github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/huh v0.6.0 github.com/charmbracelet/lipgloss v1.0.0 diff --git a/go.sum b/go.sum index 0cfaa1b..59b1eef 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/catppuccin/go v0.2.0 h1:ktBeIrIP42b/8FGiScP9sgrWOss3lw0Z5SktRoithGA= github.com/catppuccin/go v0.2.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc= github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE= github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU= -github.com/charmbracelet/bubbletea v1.2.3 h1:d9MdMsANIYZB5pE1KkRqaUV6GfsiWm+/9z4fTuGVm9I= -github.com/charmbracelet/bubbletea v1.2.3/go.mod h1:Qr6fVQw+wX7JkWWkVyXYk/ZUQ92a6XNekLXa3rR18MM= +github.com/charmbracelet/bubbletea v1.2.4 h1:KN8aCViA0eps9SCOThb2/XPIlea3ANJLUkv3KnQRNCE= +github.com/charmbracelet/bubbletea v1.2.4/go.mod h1:Qr6fVQw+wX7JkWWkVyXYk/ZUQ92a6XNekLXa3rR18MM= github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= github.com/charmbracelet/huh v0.6.0 h1:mZM8VvZGuE0hoDXq6XLxRtgfWyTI3b2jZNKh0xWmax8= From 620e645845daf7db10268f04bd709c2ee5870d64 Mon Sep 17 00:00:00 2001 From: Pranav RK <39577726+radar07@users.noreply.github.com> Date: Tue, 26 Nov 2024 21:12:27 +0530 Subject: [PATCH 054/198] feat: allow cursor option in file (#667) --- file/command.go | 1 + 1 file changed, 1 insertion(+) diff --git a/file/command.go b/file/command.go index 9d8b50f..6722119 100644 --- a/file/command.go +++ b/file/command.go @@ -43,6 +43,7 @@ func (o Options) Run() error { huh.NewFilePicker(). Picking(true). CurrentDirectory(path). + Cursor(o.Cursor). DirAllowed(o.Directory). FileAllowed(o.File). Height(o.Height). From fb11344ea410b94a92e9216f991c3d11c806c01b Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 26 Nov 2024 12:42:54 -0300 Subject: [PATCH 055/198] fix(choose): --ordered (#722) closes #687 Signed-off-by: Carlos Alexandro Becker --- choose/command.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/choose/command.go b/choose/command.go index d4b1c42..70afc14 100644 --- a/choose/command.go +++ b/choose/command.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "os" + "slices" "strings" "github.com/charmbracelet/huh" @@ -45,6 +46,12 @@ func (o Options) Run() error { theme.Focused.SelectedPrefix = o.SelectedItemStyle.ToLipgloss().SetString(o.SelectedPrefix) theme.Focused.UnselectedPrefix = o.ItemStyle.ToLipgloss().SetString(o.UnselectedPrefix) + if o.Ordered { + slices.SortFunc(options, func(a, b huh.Option[string]) int { + return strings.Compare(a.Key, b.Key) + }) + } + for _, s := range o.Selected { for i, opt := range options { if s == opt.Key || s == opt.Value { From 01f36b58a431c35e5913a29eb8573e6f62aa2c41 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 26 Nov 2024 12:43:44 -0300 Subject: [PATCH 056/198] chore(deps): use huh main Signed-off-by: Carlos Alexandro Becker --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e106803..0ee3d69 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/charmbracelet/bubbles v0.20.0 github.com/charmbracelet/bubbletea v1.2.4 github.com/charmbracelet/glamour v0.8.0 - github.com/charmbracelet/huh v0.6.0 + github.com/charmbracelet/huh v0.6.1-0.20241125235914-50e7b0ecd1da github.com/charmbracelet/lipgloss v1.0.0 github.com/charmbracelet/log v0.4.0 github.com/charmbracelet/x/ansi v0.5.2 diff --git a/go.sum b/go.sum index 59b1eef..1543775 100644 --- a/go.sum +++ b/go.sum @@ -26,8 +26,8 @@ github.com/charmbracelet/bubbletea v1.2.4 h1:KN8aCViA0eps9SCOThb2/XPIlea3ANJLUkv github.com/charmbracelet/bubbletea v1.2.4/go.mod h1:Qr6fVQw+wX7JkWWkVyXYk/ZUQ92a6XNekLXa3rR18MM= github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= -github.com/charmbracelet/huh v0.6.0 h1:mZM8VvZGuE0hoDXq6XLxRtgfWyTI3b2jZNKh0xWmax8= -github.com/charmbracelet/huh v0.6.0/go.mod h1:GGNKeWCeNzKpEOh/OJD8WBwTQjV3prFAtQPpLv+AVwU= +github.com/charmbracelet/huh v0.6.1-0.20241125235914-50e7b0ecd1da h1:q3WNIaHjiKcE3NrTeRfoQngMTvTUezIau0iF3T1sE4A= +github.com/charmbracelet/huh v0.6.1-0.20241125235914-50e7b0ecd1da/go.mod h1:zBQ8egHPGjAW+/mEDhuBq25FRmd+R6bLTDPqLMvyH7s= github.com/charmbracelet/lipgloss v1.0.0 h1:O7VkGDvqEdGi93X+DeqsQ7PKHDgtQfF8j8/O2qFMQNg= github.com/charmbracelet/lipgloss v1.0.0/go.mod h1:U5fy9Z+C38obMs+T+tJqst9VGzlOYGj4ri9reL3qUlo= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= From c3e836f0dd26dbef58dbe636088d70d23373b2c7 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 27 Nov 2024 14:58:21 -0300 Subject: [PATCH 057/198] fix(spin): interrupt child process on ctrl+c (#732) * fix(spin): interrupt child process on ctrl+c This will send a SIGINT to the child process when ctrl+c is pressed. closes #730 * fix: lint --- spin/spin.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/spin/spin.go b/spin/spin.go index 26c933f..cdfc248 100644 --- a/spin/spin.go +++ b/spin/spin.go @@ -18,6 +18,7 @@ import ( "io" "os/exec" "strings" + "syscall" "time" "github.com/charmbracelet/gum/internal/exit" @@ -48,6 +49,8 @@ var ( bothbuf strings.Builder outbuf strings.Builder errbuf strings.Builder + + executing *exec.Cmd ) type finishCommandMsg struct { @@ -64,11 +67,11 @@ func commandStart(command []string) tea.Cmd { args = command[1:] } - cmd := exec.Command(command[0], args...) //nolint:gosec - cmd.Stdout = io.MultiWriter(&bothbuf, &outbuf) - cmd.Stderr = io.MultiWriter(&bothbuf, &errbuf) - _ = cmd.Run() - status := cmd.ProcessState.ExitCode() + executing = exec.Command(command[0], args...) //nolint:gosec + executing.Stdout = io.MultiWriter(&bothbuf, &outbuf) + executing.Stderr = io.MultiWriter(&bothbuf, &errbuf) + _ = executing.Run() + status := executing.ProcessState.ExitCode() if status == -1 { status = 1 } @@ -82,6 +85,13 @@ func commandStart(command []string) tea.Cmd { } } +func commandAbort() tea.Msg { + if executing != nil && executing.Process != nil { + _ = executing.Process.Signal(syscall.SIGINT) + } + return nil +} + func (m model) Init() tea.Cmd { return tea.Batch( m.spinner.Tick, @@ -135,7 +145,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg.String() { case "ctrl+c": m.aborted = true - return m, tea.Quit + return m, commandAbort } } From fef37dae1f9bfa5b04b40ed509efc630e315a177 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 04:16:50 +0000 Subject: [PATCH 058/198] chore(deps): bump github.com/alecthomas/kong from 1.4.0 to 1.5.0 (#735) Bumps [github.com/alecthomas/kong](https://github.com/alecthomas/kong) from 1.4.0 to 1.5.0. - [Commits](https://github.com/alecthomas/kong/compare/v1.4.0...v1.5.0) --- updated-dependencies: - dependency-name: github.com/alecthomas/kong dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0ee3d69..31eaf40 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/charmbracelet/gum go 1.21 require ( - github.com/alecthomas/kong v1.4.0 + github.com/alecthomas/kong v1.5.0 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 github.com/charmbracelet/bubbletea v1.2.4 diff --git a/go.sum b/go.sum index 1543775..cc54e9d 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8v github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E= github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I= -github.com/alecthomas/kong v1.4.0 h1:UL7tzGMnnY0YRMMvJyITIRX1EpO6RbBRZDNcCevy3HA= -github.com/alecthomas/kong v1.4.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= +github.com/alecthomas/kong v1.5.0 h1:pvJ7ucmgyBrGcdHVYD3xc9rqbcnVNRQ63mYv6KNrwYs= +github.com/alecthomas/kong v1.5.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= github.com/alecthomas/mango-kong v0.1.0 h1:iFVfP1k1K4qpml3JUQmD5I8MCQYfIvsD9mRdrw7jJC4= github.com/alecthomas/mango-kong v0.1.0/go.mod h1:t+TYVdsONUolf/BwVcm+15eqcdAj15h4Qe9MMFAwwT4= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= From 90919986f21a575e3aef53b037a37e12b4d4b6f4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2024 04:28:34 +0000 Subject: [PATCH 059/198] chore(deps): bump github.com/alecthomas/kong from 1.5.0 to 1.5.1 (#736) Bumps [github.com/alecthomas/kong](https://github.com/alecthomas/kong) from 1.5.0 to 1.5.1. - [Commits](https://github.com/alecthomas/kong/compare/v1.5.0...v1.5.1) --- updated-dependencies: - dependency-name: github.com/alecthomas/kong dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 31eaf40..e512cba 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/charmbracelet/gum go 1.21 require ( - github.com/alecthomas/kong v1.5.0 + github.com/alecthomas/kong v1.5.1 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 github.com/charmbracelet/bubbletea v1.2.4 diff --git a/go.sum b/go.sum index cc54e9d..0921415 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8v github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E= github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I= -github.com/alecthomas/kong v1.5.0 h1:pvJ7ucmgyBrGcdHVYD3xc9rqbcnVNRQ63mYv6KNrwYs= -github.com/alecthomas/kong v1.5.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= +github.com/alecthomas/kong v1.5.1 h1:9quB93P2aNGXf5C1kWNei85vjBgITNJQA4dSwJQGCOY= +github.com/alecthomas/kong v1.5.1/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= github.com/alecthomas/mango-kong v0.1.0 h1:iFVfP1k1K4qpml3JUQmD5I8MCQYfIvsD9mRdrw7jJC4= github.com/alecthomas/mango-kong v0.1.0/go.mod h1:t+TYVdsONUolf/BwVcm+15eqcdAj15h4Qe9MMFAwwT4= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= From cb61fe6c8434cf9e6815355314eeb29ff3053192 Mon Sep 17 00:00:00 2001 From: ctn-malone <60197791+ctn-malone@users.noreply.github.com> Date: Tue, 3 Dec 2024 15:39:51 +0100 Subject: [PATCH 060/198] chore(nix): update src hash (#733) --- default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.nix b/default.nix index b0cdedf..f478b08 100644 --- a/default.nix +++ b/default.nix @@ -6,7 +6,7 @@ pkgs.buildGoModule rec { src = ./.; - vendorHash = "sha256-gDDaKrwlrJyyDzgyGf9iP/XPnOAwpkvIyzCXobXrlF4="; + vendorHash = "sha256-UNBDVIz2VEizkhelCjadkzd2S2yTYXecTFUpCf+XtxY="; ldflags = [ "-s" "-w" "-X=main.Version=${version}" ]; } From 63a3e8c8ce326ea97f1fd70e6266d7417a075082 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 3 Dec 2024 11:40:24 -0300 Subject: [PATCH 061/198] fix(filter): abort on ctrl+q (#721) Signed-off-by: Carlos Alexandro Becker --- choose/command.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/choose/command.go b/choose/command.go index 70afc14..8a41a1f 100644 --- a/choose/command.go +++ b/choose/command.go @@ -7,6 +7,7 @@ import ( "slices" "strings" + "github.com/charmbracelet/bubbles/key" "github.com/charmbracelet/huh" "github.com/charmbracelet/lipgloss" "github.com/charmbracelet/x/ansi" @@ -35,6 +36,8 @@ func (o Options) Run() error { } theme := huh.ThemeCharm() + keymap := huh.NewDefaultKeyMap() + keymap.Quit = key.NewBinding(key.WithKeys("ctrl+c", "ctrl+q")) options := huh.NewOptions(o.Options...) theme.Focused.Base = lipgloss.NewStyle() @@ -84,6 +87,7 @@ func (o Options) Run() error { WithWidth(width). WithShowHelp(o.ShowHelp). WithTheme(theme). + WithKeyMap(keymap). WithTimeout(o.Timeout). Run() if err != nil { @@ -109,6 +113,7 @@ func (o Options) Run() error { ). WithWidth(width). WithTheme(theme). + WithKeyMap(keymap). WithTimeout(o.Timeout). WithShowHelp(o.ShowHelp). Run() From c422e76fe3f8516021dd72fa6db6447dba33ad77 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 4 Dec 2024 09:02:06 -0300 Subject: [PATCH 062/198] fix: clarify filter --sort flag (#738) * fix: clarify filter --sort flag Signed-off-by: Carlos Alexandro Becker * fix: if sort, sort options alphabetically first * Revert "fix: if sort, sort options alphabetically first" This reverts commit 86e8fc0a5bda1e95be79529ef3cca17841e6ef8a. * fix: filter * Update filter/options.go Co-authored-by: Christian Rocha --------- Signed-off-by: Carlos Alexandro Becker Co-authored-by: Christian Rocha --- filter/command.go | 2 +- filter/options.go | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/filter/command.go b/filter/command.go index 6ae7b28..74d877d 100644 --- a/filter/command.go +++ b/filter/command.go @@ -94,7 +94,7 @@ func (o Options) Run() error { fuzzy: o.Fuzzy, timeout: o.Timeout, hasTimeout: o.Timeout > 0, - sort: o.Sort, + sort: o.Sort && o.FuzzySort, }, options...) tm, err := p.Run() diff --git a/filter/options.go b/filter/options.go index 1490c49..bf64f07 100644 --- a/filter/options.go +++ b/filter/options.go @@ -33,7 +33,10 @@ type Options struct { Height int `help:"Input height" default:"0" env:"GUM_FILTER_HEIGHT"` Value string `help:"Initial filter value" default:"" env:"GUM_FILTER_VALUE"` Reverse bool `help:"Display from the bottom of the screen" env:"GUM_FILTER_REVERSE"` - Fuzzy bool `help:"Enable fuzzy matching" default:"true" env:"GUM_FILTER_FUZZY" negatable:""` - Sort bool `help:"Sort the results" default:"true" env:"GUM_FILTER_SORT" negatable:""` + Fuzzy bool `help:"Enable fuzzy matching; otherwise match from start of word" default:"true" env:"GUM_FILTER_FUZZY" negatable:""` + FuzzySort bool `help:"Sort fuzzy results by their scores" default:"true" env:"GUM_FILTER_FUZZY_SORT" negatable:""` Timeout time.Duration `help:"Timeout until filter command aborts" default:"0s" env:"GUM_FILTER_TIMEOUT"` + + // Deprecated: use [FuzzySort]. This will be removed at some point. + Sort bool `help:"Sort fuzzy results by their scores" default:"true" env:"GUM_FILTER_FUZZY_SORT" negatable:"" hidden:""` } From 71af32ce16b6a820e4c31b10d4760f1a7bc76233 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 3 Dec 2024 12:01:02 -0300 Subject: [PATCH 063/198] fix(spin): properly redirect output closes #690 --- spin/spin.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/spin/spin.go b/spin/spin.go index cdfc248..9037cb0 100644 --- a/spin/spin.go +++ b/spin/spin.go @@ -16,6 +16,7 @@ package spin import ( "io" + "os" "os/exec" "strings" "syscall" @@ -23,6 +24,7 @@ import ( "github.com/charmbracelet/gum/internal/exit" "github.com/charmbracelet/gum/timeout" + "github.com/charmbracelet/x/term" "github.com/charmbracelet/bubbles/spinner" tea "github.com/charmbracelet/bubbletea" @@ -68,8 +70,12 @@ func commandStart(command []string) tea.Cmd { } executing = exec.Command(command[0], args...) //nolint:gosec - executing.Stdout = io.MultiWriter(&bothbuf, &outbuf) - executing.Stderr = io.MultiWriter(&bothbuf, &errbuf) + if term.IsTerminal(os.Stdout.Fd()) { + executing.Stdout = io.MultiWriter(&bothbuf, &outbuf) + executing.Stderr = io.MultiWriter(&bothbuf, &errbuf) + } else { + executing.Stdout = os.Stdout + } _ = executing.Run() status := executing.ProcessState.ExitCode() if status == -1 { From 29250f8feb19e981f348e53a4799bcd4ffca5a15 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 4 Dec 2024 10:34:22 -0300 Subject: [PATCH 064/198] fix(filter): --no-strict not working, also weird behavior (#737) - `--no-strict` was erroring as non-existent option - when `--no-strict`, we should actually create a "fake" option with whatever the user is typing Signed-off-by: Carlos Alexandro Becker --- filter/command.go | 4 +--- filter/filter.go | 12 +++++++++--- filter/options.go | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/filter/command.go b/filter/command.go index 74d877d..5b58940 100644 --- a/filter/command.go +++ b/filter/command.go @@ -95,6 +95,7 @@ func (o Options) Run() error { timeout: o.Timeout, hasTimeout: o.Timeout > 0, sort: o.Sort && o.FuzzySort, + strict: o.Strict, }, options...) tm, err := p.Run() @@ -121,9 +122,6 @@ func (o Options) Run() error { } } - if !o.Strict && len(m.textinput.Value()) != 0 && len(m.matches) == 0 { - fmt.Println(m.textinput.Value()) - } return nil } diff --git a/filter/filter.go b/filter/filter.go index 6b51e7c..b958931 100644 --- a/filter/filter.go +++ b/filter/filter.go @@ -51,6 +51,7 @@ type model struct { sort bool timeout time.Duration hasTimeout bool + strict bool } func (m model) Init() tea.Cmd { @@ -223,14 +224,19 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { // A character was entered, this likely means that the text input has // changed. This suggests that the matches are outdated, so update them. + var choices []string + if !m.strict { + choices = append(choices, m.textinput.Value()) + } + choices = append(choices, m.choices...) if m.fuzzy { if m.sort { - m.matches = fuzzy.Find(m.textinput.Value(), m.choices) + m.matches = fuzzy.Find(m.textinput.Value(), choices) } else { - m.matches = fuzzy.FindNoSort(m.textinput.Value(), m.choices) + m.matches = fuzzy.FindNoSort(m.textinput.Value(), choices) } } else { - m.matches = exactMatches(m.textinput.Value(), m.choices) + m.matches = exactMatches(m.textinput.Value(), choices) } // If the search field is empty, let's not display the matches diff --git a/filter/options.go b/filter/options.go index bf64f07..62fb057 100644 --- a/filter/options.go +++ b/filter/options.go @@ -15,7 +15,7 @@ type Options struct { Limit int `help:"Maximum number of options to pick" default:"1" group:"Selection"` NoLimit bool `help:"Pick unlimited number of options (ignores limit)" group:"Selection"` SelectIfOne bool `help:"Select the given option if there is only one" group:"Selection"` - Strict bool `help:"Only returns if anything matched. Otherwise return Filter" negatable:"true" default:"true" group:"Selection"` + Strict bool `help:"Only returns if anything matched. Otherwise return Filter" negatable:"" default:"true" group:"Selection"` SelectedPrefix string `help:"Character to indicate selected items (hidden if limit is 1)" default:" ◉ " env:"GUM_FILTER_SELECTED_PREFIX"` SelectedPrefixStyle style.Styles `embed:"" prefix:"selected-indicator." set:"defaultForeground=212" envprefix:"GUM_FILTER_SELECTED_PREFIX_"` UnselectedPrefix string `help:"Character to indicate unselected items (hidden if limit is 1)" default:" ○ " env:"GUM_FILTER_UNSELECTED_PREFIX"` From a5fb6b179890df0f5e2d89ec9cccc2c853145265 Mon Sep 17 00:00:00 2001 From: Olaf Alders Date: Fri, 6 Dec 2024 13:13:48 -0500 Subject: [PATCH 065/198] docs: quote tmux session name in code sample (#745) A tmux session name could contain a space. Quote the variable to avoid the session name being split on spaces. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 135cb9c..a538089 100644 --- a/README.md +++ b/README.md @@ -399,7 +399,7 @@ $EDITOR $(gum filter) ```bash SESSION=$(tmux list-sessions -F \#S | gum filter --placeholder "Pick session...") -tmux switch-client -t $SESSION || tmux attach -t $SESSION +tmux switch-client -t "$SESSION" || tmux attach -t "$SESSION" ``` - Pick a commit hash from `git` history From d74e9ea531415c76b2a9d0c5b3f1f092af7fde65 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 04:16:12 +0000 Subject: [PATCH 066/198] chore(deps): bump github.com/alecthomas/kong from 1.5.1 to 1.6.0 (#750) Bumps [github.com/alecthomas/kong](https://github.com/alecthomas/kong) from 1.5.1 to 1.6.0. - [Commits](https://github.com/alecthomas/kong/compare/v1.5.1...v1.6.0) --- updated-dependencies: - dependency-name: github.com/alecthomas/kong dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e512cba..3ea1598 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/charmbracelet/gum go 1.21 require ( - github.com/alecthomas/kong v1.5.1 + github.com/alecthomas/kong v1.6.0 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 github.com/charmbracelet/bubbletea v1.2.4 diff --git a/go.sum b/go.sum index 0921415..5e8a0a4 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8v github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E= github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I= -github.com/alecthomas/kong v1.5.1 h1:9quB93P2aNGXf5C1kWNei85vjBgITNJQA4dSwJQGCOY= -github.com/alecthomas/kong v1.5.1/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= +github.com/alecthomas/kong v1.6.0 h1:mwOzbdMR7uv2vul9J0FU3GYxE7ls/iX1ieMg5WIM6gE= +github.com/alecthomas/kong v1.6.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= github.com/alecthomas/mango-kong v0.1.0 h1:iFVfP1k1K4qpml3JUQmD5I8MCQYfIvsD9mRdrw7jJC4= github.com/alecthomas/mango-kong v0.1.0/go.mod h1:t+TYVdsONUolf/BwVcm+15eqcdAj15h4Qe9MMFAwwT4= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= From e30fc5ecdf854a7ea49ac0344072c80b4e4a9db1 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 9 Dec 2024 13:18:35 -0300 Subject: [PATCH 067/198] refactor: removing huh as a dep (#742) * Revert "feat: huh gum write (#525)" This reverts commit 4d5d53169e89950000015994cd694ccc9e822f08. Signed-off-by: Carlos Alexandro Becker * Revert "Use Huh for Gum Confirm (#522)" This reverts commit f7572e387ebc7e9c52cd576b244535a89496860e. Signed-off-by: Carlos Alexandro Becker * revert: Use Huh for Gum Choose (#521) Signed-off-by: Carlos Alexandro Becker * revert: feat: huh for gum input (#524) * revert: feat: huh file picker (#523) * feat: remove huh * fix: timeouts * fix: lint issues * fix(choose): quit on ctrl+q ported over 63a3e8c8ce326ea97f1fd70e6266d7417a075082 * fix: ctrl+a to reverse selection Signed-off-by: Carlos Alexandro Becker * fix: better handle spin exit codes * fix(file): bind --[no-]permissions and --[no-]size * feat(confirm): show help * fix(confirm): fix help style * fix(file): help * fix(input): --no-show-help doesn't work * fix(input): help * fix(file): keymap improvement * fix(write): focus * feat(write): ctrl+e, keymaps, help * feat(choose): help * feat(filter): help * refactor: keymaps * fix(choose): only show 'toggle all' if there's no limit * fix(choose): don't show toggle if the choices are limited to 1 * fix(filter): match choose header color * fix(filter): add space above help * fix(filter): factor help into the height setting * chore(choose,filter): use verb for navigation label in help * fix(filter): hide toggle help if limit is 1 * fix(file): factor help into height setting (#746) * fix: lint issues * fix(file): handle ctrl+c * fix: remove full help * fix: lint --------- Signed-off-by: Carlos Alexandro Becker Co-authored-by: Christian Rocha --- choose/choose.go | 316 ++++++++++++++++++++++++++++++++++++++++++ choose/command.go | 209 +++++++++++++++------------- choose/options.go | 4 +- confirm/command.go | 55 ++++---- confirm/confirm.go | 194 ++++++++++++++++++++++++++ file/command.go | 86 +++++++----- file/file.go | 125 +++++++++++++++++ file/options.go | 2 +- filter/command.go | 14 ++ filter/filter.go | 108 +++++++++++++-- filter/options.go | 3 +- go.mod | 5 +- go.sum | 10 +- input/command.go | 86 ++++++------ input/input.go | 112 +++++++++++++++ input/options.go | 2 +- internal/exit/exit.go | 22 ++- main.go | 9 +- pager/command.go | 12 +- pager/pager.go | 2 + spin/command.go | 15 +- spin/spin.go | 5 +- write/command.go | 80 ++++++----- write/options.go | 15 +- write/write.go | 189 +++++++++++++++++++++++++ 25 files changed, 1381 insertions(+), 299 deletions(-) create mode 100644 choose/choose.go create mode 100644 confirm/confirm.go create mode 100644 file/file.go create mode 100644 input/input.go create mode 100644 write/write.go diff --git a/choose/choose.go b/choose/choose.go new file mode 100644 index 0000000..42eae17 --- /dev/null +++ b/choose/choose.go @@ -0,0 +1,316 @@ +// Package choose provides an interface to choose one option from a given list +// of options. The options can be provided as (new-line separated) stdin or a +// list of arguments. +// +// It is different from the filter command as it does not provide a fuzzy +// finding input, so it is best used for smaller lists of options. +// +// Let's pick from a list of gum flavors: +// +// $ gum choose "Strawberry" "Banana" "Cherry" +package choose + +import ( + "strings" + "time" + + "github.com/charmbracelet/bubbles/help" + "github.com/charmbracelet/bubbles/key" + "github.com/charmbracelet/bubbles/paginator" + tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/gum/timeout" + "github.com/charmbracelet/lipgloss" +) + +func defaultKeymap() keymap { + return keymap{ + Down: key.NewBinding( + key.WithKeys("down", "j", "ctrl+j", "ctrl+n"), + key.WithHelp("↓", "down"), + ), + Up: key.NewBinding( + key.WithKeys("up", "k", "ctrl+k", "ctrl+p"), + key.WithHelp("↑", "up"), + ), + Right: key.NewBinding( + key.WithKeys("right", "l", "ctrl+f"), + key.WithHelp("→", "right"), + ), + Left: key.NewBinding( + key.WithKeys("left", "h", "ctrl+b"), + key.WithHelp("←", "left"), + ), + Home: key.NewBinding( + key.WithKeys("g", "home"), + key.WithHelp("g", "home"), + ), + End: key.NewBinding( + key.WithKeys("G", "end"), + key.WithHelp("G", "end"), + ), + ToggleAll: key.NewBinding( + key.WithKeys("a", "A", "ctrl+a"), + key.WithHelp("ctrl+a", "select all"), + key.WithDisabled(), + ), + Toggle: key.NewBinding( + key.WithKeys(" ", "tab", "x", "ctrl+@"), + key.WithHelp("x", "toggle"), + key.WithDisabled(), + ), + Abort: key.NewBinding( + key.WithKeys("ctrl+c", "esc"), + key.WithHelp("ctrl+c", "abort"), + ), + Submit: key.NewBinding( + key.WithKeys("enter", "ctrl+q"), + key.WithHelp("enter", "submit"), + ), + } +} + +type keymap struct { + Down, + Up, + Right, + Left, + Home, + End, + ToggleAll, + Toggle, + Abort, + Submit key.Binding +} + +// FullHelp implements help.KeyMap. +func (k keymap) FullHelp() [][]key.Binding { return nil } + +// ShortHelp implements help.KeyMap. +func (k keymap) ShortHelp() []key.Binding { + return []key.Binding{ + k.Toggle, + key.NewBinding( + key.WithKeys("up", "down", "right", "left"), + key.WithHelp("↑↓←→", "navigate"), + ), + k.Submit, + k.ToggleAll, + } +} + +type model struct { + height int + cursor string + selectedPrefix string + unselectedPrefix string + cursorPrefix string + header string + items []item + quitting bool + index int + limit int + numSelected int + currentOrder int + paginator paginator.Model + aborted bool + timedOut bool + showHelp bool + help help.Model + keymap keymap + + // styles + cursorStyle lipgloss.Style + headerStyle lipgloss.Style + itemStyle lipgloss.Style + selectedItemStyle lipgloss.Style + hasTimeout bool + timeout time.Duration +} + +type item struct { + text string + selected bool + order int +} + +func (m model) Init() tea.Cmd { + return timeout.Init(m.timeout, nil) +} + +func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { + switch msg := msg.(type) { + case tea.WindowSizeMsg: + return m, nil + case timeout.TickTimeoutMsg: + if msg.TimeoutValue <= 0 { + m.quitting = true + m.timedOut = true + // 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 + } + m.timeout = msg.TimeoutValue + return m, timeout.Tick(msg.TimeoutValue, msg.Data) + case tea.KeyMsg: + start, end := m.paginator.GetSliceBounds(len(m.items)) + km := m.keymap + switch { + case key.Matches(msg, km.Down): + m.index++ + if m.index >= len(m.items) { + m.index = 0 + m.paginator.Page = 0 + } + if m.index >= end { + m.paginator.NextPage() + } + case key.Matches(msg, km.Up): + m.index-- + if m.index < 0 { + m.index = len(m.items) - 1 + m.paginator.Page = m.paginator.TotalPages - 1 + } + if m.index < start { + m.paginator.PrevPage() + } + case key.Matches(msg, km.Right): + m.index = clamp(m.index+m.height, 0, len(m.items)-1) + m.paginator.NextPage() + case key.Matches(msg, km.Left): + m.index = clamp(m.index-m.height, 0, len(m.items)-1) + m.paginator.PrevPage() + case key.Matches(msg, km.End): + m.index = len(m.items) - 1 + m.paginator.Page = m.paginator.TotalPages - 1 + case key.Matches(msg, km.Home): + m.index = 0 + m.paginator.Page = 0 + case key.Matches(msg, km.ToggleAll): + if m.limit <= 1 { + break + } + if m.numSelected < len(m.items) && m.numSelected < m.limit { + m = m.selectAll() + } else { + m = m.deselectAll() + } + case key.Matches(msg, km.Abort): + m.aborted = true + m.quitting = true + return m, tea.Quit + case key.Matches(msg, km.Toggle): + if m.limit == 1 { + break // no op + } + + if m.items[m.index].selected { + m.items[m.index].selected = false + m.numSelected-- + } else if m.numSelected < m.limit { + m.items[m.index].selected = true + m.items[m.index].order = m.currentOrder + m.numSelected++ + m.currentOrder++ + } + case key.Matches(msg, km.Submit): + m.quitting = true + if m.limit <= 1 && m.numSelected < 1 { + m.items[m.index].selected = true + } + return m, tea.Quit + } + } + + var cmd tea.Cmd + m.paginator, cmd = m.paginator.Update(msg) + return m, cmd +} + +func (m model) selectAll() model { + for i := range m.items { + if m.numSelected >= m.limit { + break // do not exceed given limit + } + if m.items[i].selected { + continue + } + m.items[i].selected = true + m.items[i].order = m.currentOrder + m.numSelected++ + m.currentOrder++ + } + return m +} + +func (m model) deselectAll() model { + for i := range m.items { + m.items[i].selected = false + m.items[i].order = 0 + } + m.numSelected = 0 + m.currentOrder = 0 + return m +} + +func (m model) View() string { + if m.quitting { + return "" + } + + var s strings.Builder + var timeoutStr string + + start, end := m.paginator.GetSliceBounds(len(m.items)) + for i, item := range m.items[start:end] { + if i == m.index%m.height { + s.WriteString(m.cursorStyle.Render(m.cursor)) + } else { + s.WriteString(strings.Repeat(" ", lipgloss.Width(m.cursor))) + } + + if item.selected { + if m.hasTimeout { + timeoutStr = timeout.Str(m.timeout) + } + s.WriteString(m.selectedItemStyle.Render(m.selectedPrefix + item.text + timeoutStr)) + } else if i == m.index%m.height { + s.WriteString(m.cursorStyle.Render(m.cursorPrefix + item.text)) + } else { + s.WriteString(m.itemStyle.Render(m.unselectedPrefix + item.text)) + } + if i != m.height { + s.WriteRune('\n') + } + } + + if m.paginator.TotalPages > 1 { + s.WriteString(strings.Repeat("\n", m.height-m.paginator.ItemsOnPage(len(m.items))+1)) + s.WriteString(" " + m.paginator.View()) + } + + var parts []string + + if m.header != "" { + parts = append(parts, m.headerStyle.Render(m.header)) + } + parts = append(parts, s.String()) + if m.showHelp { + parts = append(parts, m.help.View(m.keymap)) + } + + return lipgloss.JoinVertical(lipgloss.Left, parts...) +} + +func clamp(x, low, high int) int { + if x < low { + return low + } + if x > high { + return high + } + return x +} diff --git a/choose/command.go b/choose/command.go index 8a41a1f..26e6e23 100644 --- a/choose/command.go +++ b/choose/command.go @@ -5,10 +5,12 @@ import ( "fmt" "os" "slices" + "sort" "strings" - "github.com/charmbracelet/bubbles/key" - "github.com/charmbracelet/huh" + "github.com/charmbracelet/bubbles/help" + "github.com/charmbracelet/bubbles/paginator" + tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" "github.com/charmbracelet/x/ansi" "github.com/charmbracelet/x/term" @@ -17,11 +19,14 @@ import ( "github.com/charmbracelet/gum/internal/stdin" ) -const widthBuffer = 2 - // Run provides a shell script interface for choosing between different through // options. func (o Options) Run() error { + var ( + subduedStyle = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "#847A85", Dark: "#979797"}) + verySubduedStyle = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "#DDDADA", Dark: "#3C3C3C"}) + ) + if len(o.Options) <= 0 { input, _ := stdin.Read() if input == "" { @@ -35,116 +40,120 @@ func (o Options) Run() error { return nil } - theme := huh.ThemeCharm() - keymap := huh.NewDefaultKeyMap() - keymap.Quit = key.NewBinding(key.WithKeys("ctrl+c", "ctrl+q")) - options := huh.NewOptions(o.Options...) - - theme.Focused.Base = lipgloss.NewStyle() - theme.Focused.Title = o.HeaderStyle.ToLipgloss() - theme.Focused.SelectSelector = o.CursorStyle.ToLipgloss().SetString(o.Cursor) - theme.Focused.MultiSelectSelector = o.CursorStyle.ToLipgloss().SetString(o.Cursor) - theme.Focused.SelectedOption = o.SelectedItemStyle.ToLipgloss() - theme.Focused.UnselectedOption = o.ItemStyle.ToLipgloss() - theme.Focused.SelectedPrefix = o.SelectedItemStyle.ToLipgloss().SetString(o.SelectedPrefix) - theme.Focused.UnselectedPrefix = o.ItemStyle.ToLipgloss().SetString(o.UnselectedPrefix) - - if o.Ordered { - slices.SortFunc(options, func(a, b huh.Option[string]) int { - return strings.Compare(a.Key, b.Key) - }) + // We don't need to display prefixes if we are only picking one option. + // Simply displaying the cursor is enough. + if o.Limit == 1 && !o.NoLimit { + o.SelectedPrefix = "" + o.UnselectedPrefix = "" + o.CursorPrefix = "" } - for _, s := range o.Selected { - for i, opt := range options { - if s == opt.Key || s == opt.Value { - options[i] = opt.Selected(true) - } - } - } - - width := max(widest(o.Options)+ - max(lipgloss.Width(o.SelectedPrefix)+lipgloss.Width(o.UnselectedPrefix))+ - lipgloss.Width(o.Cursor)+1, lipgloss.Width(o.Header)+widthBuffer) - if o.NoLimit { - o.Limit = 0 + o.Limit = len(o.Options) + 1 } - if o.Limit > 1 || o.NoLimit { - var choices []string - - field := huh.NewMultiSelect[string](). - Options(options...). - Title(o.Header). - Height(o.Height). - Limit(o.Limit). - Value(&choices) - - form := huh.NewForm(huh.NewGroup(field)) - - err := form. - WithWidth(width). - WithShowHelp(o.ShowHelp). - WithTheme(theme). - WithKeyMap(keymap). - WithTimeout(o.Timeout). - Run() - if err != nil { - return exit.Handle(err, o.Timeout) - } - if len(choices) > 0 { - s := strings.Join(choices, "\n") - ansiprint(s) - } - return nil + if o.Ordered { + slices.SortFunc(o.Options, strings.Compare) } - var choice string + // Keep track of the selected items. + currentSelected := 0 + // Check if selected items should be used. + hasSelectedItems := len(o.Selected) > 0 + startingIndex := 0 + currentOrder := 0 + items := make([]item, len(o.Options)) + for i, option := range o.Options { + var order int + // Check if the option should be selected. + isSelected := hasSelectedItems && currentSelected < o.Limit && slices.Contains(o.Selected, option) + // If the option is selected then increment the current selected count. + if isSelected { + if o.Limit == 1 { + // When the user can choose only one option don't select the option but + // start with the cursor hovering over it. + startingIndex = i + isSelected = false + } else { + currentSelected++ + order = currentOrder + currentOrder++ + } + } + items[i] = item{text: option, selected: isSelected, order: order} + } - err := huh.NewForm( - huh.NewGroup( - huh.NewSelect[string](). - Options(options...). - Title(o.Header). - Height(o.Height). - Value(&choice), - ), - ). - WithWidth(width). - WithTheme(theme). - WithKeyMap(keymap). - WithTimeout(o.Timeout). - WithShowHelp(o.ShowHelp). - Run() + // Use the pagination model to display the current and total number of + // pages. + pager := paginator.New() + pager.SetTotalPages((len(items) + o.Height - 1) / o.Height) + pager.PerPage = o.Height + pager.Type = paginator.Dots + pager.ActiveDot = subduedStyle.Render("•") + pager.InactiveDot = verySubduedStyle.Render("•") + pager.KeyMap = paginator.KeyMap{} + pager.Page = startingIndex / o.Height + + km := defaultKeymap() + if o.NoLimit || o.Limit > 1 { + km.Toggle.SetEnabled(true) + } + if o.NoLimit { + km.ToggleAll.SetEnabled(true) + } + + // Disable Keybindings since we will control it ourselves. + tm, err := tea.NewProgram(model{ + index: startingIndex, + currentOrder: currentOrder, + height: o.Height, + cursor: o.Cursor, + header: o.Header, + selectedPrefix: o.SelectedPrefix, + unselectedPrefix: o.UnselectedPrefix, + cursorPrefix: o.CursorPrefix, + items: items, + limit: o.Limit, + paginator: pager, + cursorStyle: o.CursorStyle.ToLipgloss(), + headerStyle: o.HeaderStyle.ToLipgloss(), + itemStyle: o.ItemStyle.ToLipgloss(), + selectedItemStyle: o.SelectedItemStyle.ToLipgloss(), + numSelected: currentSelected, + hasTimeout: o.Timeout > 0, + timeout: o.Timeout, + showHelp: o.ShowHelp, + help: help.New(), + keymap: km, + }, tea.WithOutput(os.Stderr)).Run() if err != nil { - return exit.Handle(err, o.Timeout) + return fmt.Errorf("failed to start tea program: %w", err) + } + m := tm.(model) + if m.aborted { + return exit.ErrAborted + } + if m.timedOut { + return exit.ErrTimeout + } + if o.Ordered && o.Limit > 1 { + sort.Slice(m.items, func(i, j int) bool { + return m.items[i].order < m.items[j].order + }) + } + var s strings.Builder + for _, item := range m.items { + if item.selected { + s.WriteString(item.text) + s.WriteRune('\n') + } } if term.IsTerminal(os.Stdout.Fd()) { - fmt.Println(choice) + fmt.Print(s.String()) } else { - fmt.Print(ansi.Strip(choice)) + fmt.Print(ansi.Strip(s.String())) } return nil } - -func widest(options []string) int { - var maxw int - for _, o := range options { - w := lipgloss.Width(o) - if w > maxw { - maxw = w - } - } - return maxw -} - -func ansiprint(s string) { - if term.IsTerminal(os.Stdout.Fd()) { - fmt.Println(s) - } else { - fmt.Print(ansi.Strip(s)) - } -} diff --git a/choose/options.go b/choose/options.go index b02b05d..ff11c92 100644 --- a/choose/options.go +++ b/choose/options.go @@ -12,9 +12,9 @@ type Options struct { Limit int `help:"Maximum number of options to pick" default:"1" group:"Selection"` NoLimit bool `help:"Pick unlimited number of options (ignores limit)" group:"Selection"` Ordered bool `help:"Maintain the order of the selected options" env:"GUM_CHOOSE_ORDERED"` - Height int `help:"Height of the list" default:"0" env:"GUM_CHOOSE_HEIGHT"` + Height int `help:"Height of the list" default:"10" env:"GUM_CHOOSE_HEIGHT"` Cursor string `help:"Prefix to show on item that corresponds to the cursor position" default:"> " env:"GUM_CHOOSE_CURSOR"` - ShowHelp bool `help:"Show help keybinds" default:"true" negatable:"true" env:"GUM_CHOOSE_SHOW_HELP"` + ShowHelp bool `help:"Show help keybinds" default:"true" negatable:"" env:"GUM_CHOOSE_SHOW_HELP"` Header string `help:"Header value" default:"Choose:" env:"GUM_CHOOSE_HEADER"` CursorPrefix string `help:"Prefix to show on the cursor item (hidden if limit is 1)" default:"• " env:"GUM_CHOOSE_CURSOR_PREFIX"` SelectedPrefix string `help:"Prefix to show on selected items (hidden if limit is 1)" default:"✓ " env:"GUM_CHOOSE_SELECTED_PREFIX"` diff --git a/confirm/command.go b/confirm/command.go index 3653502..e31dd9f 100644 --- a/confirm/command.go +++ b/confirm/command.go @@ -1,42 +1,47 @@ package confirm import ( + "errors" "os" + "github.com/charmbracelet/bubbles/help" "github.com/charmbracelet/gum/internal/exit" - "github.com/charmbracelet/huh" + + tea "github.com/charmbracelet/bubbletea" ) // Run provides a shell script interface for prompting a user to confirm an // action with an affirmative or negative answer. func (o Options) Run() error { - theme := huh.ThemeCharm() - theme.Focused.Title = o.PromptStyle.ToLipgloss() - theme.Focused.FocusedButton = o.SelectedStyle.ToLipgloss() - theme.Focused.BlurredButton = o.UnselectedStyle.ToLipgloss() - - choice := o.Default - - err := huh.NewForm( - huh.NewGroup( - huh.NewConfirm(). - Affirmative(o.Affirmative). - Negative(o.Negative). - Title(o.Prompt). - Value(&choice), - ), - ). - WithTimeout(o.Timeout). - WithTheme(theme). - WithShowHelp(o.ShowHelp). - Run() + tm, err := tea.NewProgram(model{ + affirmative: o.Affirmative, + negative: o.Negative, + confirmation: o.Default, + defaultSelection: o.Default, + timeout: o.Timeout, + hasTimeout: o.Timeout > 0, + keys: defaultKeymap(o.Affirmative, o.Negative), + help: help.New(), + showHelp: o.ShowHelp, + prompt: o.Prompt, + selectedStyle: o.SelectedStyle.ToLipgloss(), + unselectedStyle: o.UnselectedStyle.ToLipgloss(), + promptStyle: o.PromptStyle.ToLipgloss(), + }, tea.WithOutput(os.Stderr)).Run() if err != nil { - return exit.Handle(err, o.Timeout) + return err } - if !choice { - os.Exit(1) + m := tm.(model) + if m.timedOut { + return exit.ErrTimeout + } + if m.aborted { + return exit.ErrAborted + } + if m.confirmation { + return nil } - return nil + return errors.New("not confirmed") } diff --git a/confirm/confirm.go b/confirm/confirm.go new file mode 100644 index 0000000..c258068 --- /dev/null +++ b/confirm/confirm.go @@ -0,0 +1,194 @@ +// Package confirm provides an interface to ask a user to confirm an action. +// The user is provided with an interface to choose an affirmative or negative +// answer, which is then reflected in the exit code for use in scripting. +// +// If the user selects the affirmative answer, the program exits with 0. If the +// user selects the negative answer, the program exits with 1. +// +// I.e. confirm if the user wants to delete a file +// +// $ gum confirm "Are you sure?" && rm file.txt +package confirm + +import ( + "time" + + "github.com/charmbracelet/bubbles/help" + "github.com/charmbracelet/bubbles/key" + "github.com/charmbracelet/gum/timeout" + + tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/lipgloss" +) + +func defaultKeymap(affirmative, negative string) keymap { + return keymap{ + Abort: key.NewBinding( + key.WithKeys("ctrl+c"), + key.WithHelp("ctrl+c", "cancel"), + ), + Quit: key.NewBinding( + key.WithKeys("esc"), + key.WithHelp("esc", "quit"), + ), + Negative: key.NewBinding( + key.WithKeys("n", "N", "q"), + key.WithHelp("n", negative), + ), + Affirmative: key.NewBinding( + key.WithKeys("y", "Y"), + key.WithHelp("y", affirmative), + ), + Toggle: key.NewBinding( + key.WithKeys( + "left", + "h", + "ctrl+n", + "shift+tab", + "right", + "l", + "ctrl+p", + "tab", + ), + key.WithHelp("←/→", "toggle"), + ), + Submit: key.NewBinding( + key.WithKeys("enter"), + key.WithHelp("enter", "submit"), + ), + } +} + +type keymap struct { + Abort key.Binding + Quit key.Binding + Negative key.Binding + Affirmative key.Binding + Toggle key.Binding + Submit key.Binding +} + +// FullHelp implements help.KeyMap. +func (k keymap) FullHelp() [][]key.Binding { return nil } + +// ShortHelp implements help.KeyMap. +func (k keymap) ShortHelp() []key.Binding { + return []key.Binding{k.Toggle, k.Submit, k.Affirmative, k.Negative} +} + +type model struct { + prompt string + affirmative string + negative string + quitting bool + aborted bool + hasTimeout bool + showHelp bool + help help.Model + keys keymap + timeout time.Duration + + confirmation bool + timedOut bool + + defaultSelection bool + + // styles + promptStyle lipgloss.Style + selectedStyle lipgloss.Style + unselectedStyle lipgloss.Style +} + +func (m model) Init() tea.Cmd { + return timeout.Init(m.timeout, m.defaultSelection) +} + +func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { + switch msg := msg.(type) { + case tea.WindowSizeMsg: + return m, nil + case tea.KeyMsg: + switch { + case key.Matches(msg, m.keys.Abort): + m.confirmation = false + m.aborted = true + fallthrough + case key.Matches(msg, m.keys.Quit): + m.confirmation = false + m.quitting = true + return m, tea.Quit + case key.Matches(msg, m.keys.Negative): + m.confirmation = false + m.quitting = true + return m, tea.Quit + case key.Matches(msg, m.keys.Toggle): + if m.negative == "" { + break + } + m.confirmation = !m.confirmation + case key.Matches(msg, m.keys.Submit): + m.quitting = true + return m, tea.Quit + case key.Matches(msg, m.keys.Affirmative): + m.quitting = true + m.confirmation = true + return m, tea.Quit + } + case timeout.TickTimeoutMsg: + if msg.TimeoutValue <= 0 { + m.quitting = true + m.confirmation = m.defaultSelection + m.timedOut = true + return m, tea.Quit + } + + m.timeout = msg.TimeoutValue + return m, timeout.Tick(msg.TimeoutValue, msg.Data) + } + return m, nil +} + +func (m model) View() string { + if m.quitting { + return "" + } + + var aff, neg, timeoutStrYes, timeoutStrNo string + timeoutStrNo = "" + timeoutStrYes = "" + if m.hasTimeout { + if m.defaultSelection { + timeoutStrYes = timeout.Str(m.timeout) + } else { + timeoutStrNo = timeout.Str(m.timeout) + } + } + + if m.confirmation { + aff = m.selectedStyle.Render(m.affirmative + timeoutStrYes) + neg = m.unselectedStyle.Render(m.negative + timeoutStrNo) + } else { + aff = m.unselectedStyle.Render(m.affirmative + timeoutStrYes) + neg = m.selectedStyle.Render(m.negative + timeoutStrNo) + } + + // If the option is intentionally empty, do not show it. + if m.negative == "" { + neg = "" + } + + if m.showHelp { + return lipgloss.JoinVertical( + lipgloss.Left, + m.promptStyle.Render(m.prompt)+"\n", + lipgloss.JoinHorizontal(lipgloss.Left, aff, neg), + "\n"+m.help.View(m.keys), + ) + } + + return lipgloss.JoinVertical( + lipgloss.Left, + m.promptStyle.Render(m.prompt)+"\n", + lipgloss.JoinHorizontal(lipgloss.Left, aff, neg), + ) +} diff --git a/file/command.go b/file/command.go index 6722119..6c6d26e 100644 --- a/file/command.go +++ b/file/command.go @@ -3,11 +3,13 @@ package file import ( "errors" "fmt" + "os" "path/filepath" + "github.com/charmbracelet/bubbles/filepicker" + "github.com/charmbracelet/bubbles/help" + tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/gum/internal/exit" - "github.com/charmbracelet/huh" - "github.com/charmbracelet/lipgloss" ) // Run is the interface to picking a file. @@ -25,42 +27,50 @@ func (o Options) Run() error { return fmt.Errorf("file not found: %w", err) } - theme := huh.ThemeCharm() - theme.Focused.Base = lipgloss.NewStyle() - theme.Focused.File = o.FileStyle.ToLipgloss() - theme.Focused.Directory = o.DirectoryStyle.ToLipgloss() - theme.Focused.SelectedOption = o.SelectedStyle.ToLipgloss() - - keymap := huh.NewDefaultKeyMap() - keymap.FilePicker.Open.SetEnabled(false) - - // XXX: These should be file selected specific. - theme.Focused.TextInput.Placeholder = o.PermissionsStyle.ToLipgloss() - theme.Focused.TextInput.Prompt = o.CursorStyle.ToLipgloss() - - err = huh.NewForm( - huh.NewGroup( - huh.NewFilePicker(). - Picking(true). - CurrentDirectory(path). - Cursor(o.Cursor). - DirAllowed(o.Directory). - FileAllowed(o.File). - Height(o.Height). - ShowHidden(o.All). - ShowSize(o.Size). - ShowPermissions(o.Permissions). - Value(&path), - ), - ). - WithTimeout(o.Timeout). - WithShowHelp(o.ShowHelp). - WithKeyMap(keymap). - WithTheme(theme). - Run() - if err != nil { - return exit.Handle(err, o.Timeout) + fp := filepicker.New() + fp.CurrentDirectory = path + fp.Path = path + fp.Height = o.Height + fp.AutoHeight = o.Height == 0 + fp.Cursor = o.Cursor + fp.DirAllowed = o.Directory + fp.FileAllowed = o.File + fp.ShowPermissions = o.Permissions + fp.ShowSize = o.Size + fp.ShowHidden = o.All + fp.Styles = filepicker.DefaultStyles() + fp.Styles.Cursor = o.CursorStyle.ToLipgloss() + fp.Styles.Symlink = o.SymlinkStyle.ToLipgloss() + fp.Styles.Directory = o.DirectoryStyle.ToLipgloss() + fp.Styles.File = o.FileStyle.ToLipgloss() + fp.Styles.Permission = o.PermissionsStyle.ToLipgloss() + fp.Styles.Selected = o.SelectedStyle.ToLipgloss() + fp.Styles.FileSize = o.FileSizeStyle.ToLipgloss() + m := model{ + filepicker: fp, + timeout: o.Timeout, + hasTimeout: o.Timeout > 0, + aborted: false, + showHelp: o.ShowHelp, + help: help.New(), + keymap: defaultKeymap(), } - fmt.Println(path) + + tm, err := tea.NewProgram(&m, tea.WithOutput(os.Stderr)).Run() + if err != nil { + return fmt.Errorf("unable to pick selection: %w", err) + } + m = tm.(model) + if m.aborted { + return exit.ErrAborted + } + if m.timedOut { + return exit.ErrTimeout + } + if m.selectedPath == "" { + return errors.New("no file selected") + } + + fmt.Println(m.selectedPath) return nil } diff --git a/file/file.go b/file/file.go new file mode 100644 index 0000000..b327768 --- /dev/null +++ b/file/file.go @@ -0,0 +1,125 @@ +// Package file provides an interface to pick a file from a folder (tree). +// The user is provided a file manager-like interface to navigate, to +// select a file. +// +// Let's pick a file from the current directory: +// +// $ gum file +// $ gum file . +// +// Let's pick a file from the home directory: +// +// $ gum file $HOME +package file + +import ( + "time" + + "github.com/charmbracelet/bubbles/filepicker" + "github.com/charmbracelet/bubbles/help" + "github.com/charmbracelet/bubbles/key" + tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/gum/timeout" + "github.com/charmbracelet/lipgloss" +) + +type keymap filepicker.KeyMap + +var keyQuit = key.NewBinding( + key.WithKeys("esc", "q"), + key.WithHelp("esc", "close"), +) + +var keyAbort = key.NewBinding( + key.WithKeys("ctrl+c"), + key.WithHelp("ctrl+c", "abort"), +) + +func defaultKeymap() keymap { + km := filepicker.DefaultKeyMap() + km.Down.SetHelp("↓", "down") + km.Up.SetHelp("↑", "up") + return keymap(km) +} + +// FullHelp implements help.KeyMap. +func (k keymap) FullHelp() [][]key.Binding { return nil } + +// ShortHelp implements help.KeyMap. +func (k keymap) ShortHelp() []key.Binding { + return []key.Binding{ + k.Up, + k.Down, + keyQuit, + k.Select, + } +} + +type model struct { + filepicker filepicker.Model + selectedPath string + aborted bool + timedOut bool + quitting bool + timeout time.Duration + hasTimeout bool + showHelp bool + help help.Model + keymap keymap +} + +func (m model) Init() tea.Cmd { + return tea.Batch( + timeout.Init(m.timeout, nil), + m.filepicker.Init(), + ) +} + +func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { + switch msg := msg.(type) { + case tea.WindowSizeMsg: + if m.showHelp { + m.filepicker.Height -= lipgloss.Height(m.helpView()) + } + case tea.KeyMsg: + switch { + case key.Matches(msg, keyAbort): + m.aborted = true + m.quitting = true + return m, tea.Quit + case key.Matches(msg, keyQuit): + m.quitting = true + return m, tea.Quit + } + case timeout.TickTimeoutMsg: + if msg.TimeoutValue <= 0 { + m.quitting = true + m.timedOut = true + return m, tea.Quit + } + m.timeout = msg.TimeoutValue + return m, timeout.Tick(msg.TimeoutValue, msg.Data) + } + var cmd tea.Cmd + m.filepicker, cmd = m.filepicker.Update(msg) + if didSelect, path := m.filepicker.DidSelectFile(msg); didSelect { + m.selectedPath = path + m.quitting = true + return m, tea.Quit + } + return m, cmd +} + +func (m model) View() string { + if m.quitting { + return "" + } + if !m.showHelp { + return m.filepicker.View() + } + return m.filepicker.View() + m.helpView() +} + +func (m model) helpView() string { + return "\n" + m.help.View(m.keymap) +} diff --git a/file/options.go b/file/options.go index 0f8f9af..2aa5e5b 100644 --- a/file/options.go +++ b/file/options.go @@ -19,7 +19,7 @@ type Options struct { Directory bool `help:"Allow directories selection" default:"false" env:"GUM_FILE_DIRECTORY"` ShowHelp bool `help:"Show help key binds" negatable:"" default:"true" env:"GUM_FILE_SHOW_HELP"` - Height int `help:"Maximum number of files to display" default:"0" env:"GUM_FILE_HEIGHT"` + Height int `help:"Maximum number of files to display" default:"10" env:"GUM_FILE_HEIGHT"` CursorStyle style.Styles `embed:"" prefix:"cursor." help:"The cursor style" set:"defaultForeground=212" envprefix:"GUM_FILE_CURSOR_"` SymlinkStyle style.Styles `embed:"" prefix:"symlink." help:"The style to use for symlinks" set:"defaultForeground=36" envprefix:"GUM_FILE_SYMLINK_"` DirectoryStyle style.Styles `embed:"" prefix:"directory." help:"The style to use for directories" set:"defaultForeground=99" envprefix:"GUM_FILE_DIRECTORY_"` diff --git a/filter/command.go b/filter/command.go index 5b58940..15093ad 100644 --- a/filter/command.go +++ b/filter/command.go @@ -6,6 +6,7 @@ import ( "os" "strings" + "github.com/charmbracelet/bubbles/help" "github.com/charmbracelet/bubbles/textinput" "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" @@ -67,9 +68,16 @@ func (o Options) Run() error { matches = matchAll(o.Options) } + km := defaultKeymap() + if o.NoLimit { o.Limit = len(o.Options) } + if o.NoLimit || o.Limit > 1 { + km.Toggle.SetEnabled(true) + km.ToggleAndPrevious.SetEnabled(true) + km.ToggleAndNext.SetEnabled(true) + } p := tea.NewProgram(model{ choices: o.Options, @@ -96,6 +104,9 @@ func (o Options) Run() error { hasTimeout: o.Timeout > 0, sort: o.Sort && o.FuzzySort, strict: o.Strict, + showHelp: o.ShowHelp, + keymap: km, + help: help.New(), }, options...) tm, err := p.Run() @@ -106,6 +117,9 @@ func (o Options) Run() error { if m.aborted { return exit.ErrAborted } + if m.timedOut { + return exit.ErrTimeout + } isTTY := term.IsTerminal(os.Stdout.Fd()) diff --git a/filter/filter.go b/filter/filter.go index b958931..956d502 100644 --- a/filter/filter.go +++ b/filter/filter.go @@ -16,6 +16,8 @@ import ( "github.com/charmbracelet/gum/timeout" + "github.com/charmbracelet/bubbles/help" + "github.com/charmbracelet/bubbles/key" "github.com/charmbracelet/bubbles/textinput" "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" @@ -23,6 +25,67 @@ import ( "github.com/sahilm/fuzzy" ) +func defaultKeymap() keymap { + return keymap{ + Down: key.NewBinding( + key.WithKeys("down", "ctrl+j", "ctrl+n"), + key.WithHelp("↓", "down"), + ), + Up: key.NewBinding( + key.WithKeys("up", "ctrl+k", "ctrl+p"), + key.WithHelp("↑", "up"), + ), + ToggleAndNext: key.NewBinding( + key.WithKeys("tab"), + key.WithHelp("tab", "toggle"), + key.WithDisabled(), + ), + ToggleAndPrevious: key.NewBinding( + key.WithKeys("shift+tab"), + key.WithHelp("shift+tab", "toggle"), + key.WithDisabled(), + ), + Toggle: key.NewBinding( + key.WithKeys("ctrl+@"), + key.WithHelp("ctrl+@", "toggle"), + key.WithDisabled(), + ), + Abort: key.NewBinding( + key.WithKeys("ctrl+c", "esc"), + key.WithHelp("ctrl+c", "abort"), + ), + Submit: key.NewBinding( + key.WithKeys("enter", "ctrl+q"), + key.WithHelp("enter", "submit"), + ), + } +} + +type keymap struct { + Down, + Up, + ToggleAndNext, + ToggleAndPrevious, + Toggle, + Abort, + Submit key.Binding +} + +// FullHelp implements help.KeyMap. +func (k keymap) FullHelp() [][]key.Binding { return nil } + +// ShortHelp implements help.KeyMap. +func (k keymap) ShortHelp() []key.Binding { + return []key.Binding{ + k.ToggleAndNext, + key.NewBinding( + key.WithKeys("up", "down"), + key.WithHelp("↑↓", "navigate"), + ), + k.Submit, + } +} + type model struct { textinput textinput.Model viewport *viewport.Model @@ -38,6 +101,7 @@ type model struct { unselectedPrefix string height int aborted bool + timedOut bool quitting bool headerStyle lipgloss.Style matchStyle lipgloss.Style @@ -49,6 +113,9 @@ type model struct { reverse bool fuzzy bool sort bool + showHelp bool + keymap keymap + help help.Model timeout time.Duration hasTimeout bool strict bool @@ -137,10 +204,18 @@ func (m model) View() string { m.viewport.SetContent(s.String()) + help := "" + if m.showHelp { + help = m.helpView() + } + // View the input and the filtered choices header := m.headerStyle.Render(m.header) if m.reverse { view := m.viewport.View() + "\n" + m.textinput.View() + if m.showHelp { + view += help + } if m.header != "" { return lipgloss.JoinVertical(lipgloss.Left, view, header) } @@ -149,19 +224,26 @@ func (m model) View() string { } view := m.textinput.View() + "\n" + m.viewport.View() + if m.showHelp { + view += help + } if m.header != "" { return lipgloss.JoinVertical(lipgloss.Left, header, view) } return view } +func (m model) helpView() string { + return "\n\n" + m.help.View(m.keymap) +} + func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { var cmd tea.Cmd switch msg := msg.(type) { case timeout.TickTimeoutMsg: if msg.TimeoutValue <= 0 { m.quitting = true - m.aborted = true + m.timedOut = true return m, tea.Quit } m.timeout = msg.TimeoutValue @@ -171,41 +253,45 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if m.height == 0 || m.height > msg.Height { m.viewport.Height = msg.Height - lipgloss.Height(m.textinput.View()) } - - // Make place in the view port if header is set + // Include the header in the height calculation. if m.header != "" { m.viewport.Height = m.viewport.Height - lipgloss.Height(m.headerStyle.Render(m.header)) } + // Include the help in the total height calculation. + if m.showHelp { + m.viewport.Height = m.viewport.Height - lipgloss.Height(m.helpView()) + } m.viewport.Width = msg.Width if m.reverse { m.viewport.YOffset = clamp(0, len(m.matches), len(m.matches)-m.viewport.Height) } case tea.KeyMsg: - switch msg.String() { - case "ctrl+c", "esc": + km := m.keymap + switch { + case key.Matches(msg, km.Abort): m.aborted = true m.quitting = true return m, tea.Quit - case "enter": + case key.Matches(msg, km.Submit): m.quitting = true return m, tea.Quit - case "ctrl+n", "ctrl+j", "down": + case key.Matches(msg, km.Down): m.CursorDown() - case "ctrl+p", "ctrl+k", "up": + case key.Matches(msg, km.Up): m.CursorUp() - case "tab": + case key.Matches(msg, km.ToggleAndNext): if m.limit == 1 { break // no op } m.ToggleSelection() m.CursorDown() - case "shift+tab": + case key.Matches(msg, km.ToggleAndPrevious): if m.limit == 1 { break // no op } m.ToggleSelection() m.CursorUp() - case "ctrl+@": + case key.Matches(msg, km.Toggle): if m.limit == 1 { break // no op } diff --git a/filter/options.go b/filter/options.go index 62fb057..3cdefe8 100644 --- a/filter/options.go +++ b/filter/options.go @@ -15,12 +15,13 @@ type Options struct { Limit int `help:"Maximum number of options to pick" default:"1" group:"Selection"` NoLimit bool `help:"Pick unlimited number of options (ignores limit)" group:"Selection"` SelectIfOne bool `help:"Select the given option if there is only one" group:"Selection"` + ShowHelp bool `help:"Show help keybinds" default:"true" negatable:"" env:"GUM_FILTER_SHOW_HELP"` Strict bool `help:"Only returns if anything matched. Otherwise return Filter" negatable:"" default:"true" group:"Selection"` SelectedPrefix string `help:"Character to indicate selected items (hidden if limit is 1)" default:" ◉ " env:"GUM_FILTER_SELECTED_PREFIX"` SelectedPrefixStyle style.Styles `embed:"" prefix:"selected-indicator." set:"defaultForeground=212" envprefix:"GUM_FILTER_SELECTED_PREFIX_"` UnselectedPrefix string `help:"Character to indicate unselected items (hidden if limit is 1)" default:" ○ " env:"GUM_FILTER_UNSELECTED_PREFIX"` UnselectedPrefixStyle style.Styles `embed:"" prefix:"unselected-prefix." set:"defaultForeground=240" envprefix:"GUM_FILTER_UNSELECTED_PREFIX_"` - HeaderStyle style.Styles `embed:"" prefix:"header." set:"defaultForeground=240" envprefix:"GUM_FILTER_HEADER_"` + HeaderStyle style.Styles `embed:"" prefix:"header." set:"defaultForeground=99" envprefix:"GUM_FILTER_HEADER_"` Header string `help:"Header value" default:"" env:"GUM_FILTER_HEADER"` TextStyle style.Styles `embed:"" prefix:"text." envprefix:"GUM_FILTER_TEXT_"` CursorTextStyle style.Styles `embed:"" prefix:"cursor-text." envprefix:"GUM_FILTER_CURSOR_TEXT_"` diff --git a/go.mod b/go.mod index 3ea1598..88df801 100644 --- a/go.mod +++ b/go.mod @@ -8,10 +8,10 @@ require ( github.com/charmbracelet/bubbles v0.20.0 github.com/charmbracelet/bubbletea v1.2.4 github.com/charmbracelet/glamour v0.8.0 - github.com/charmbracelet/huh v0.6.1-0.20241125235914-50e7b0ecd1da github.com/charmbracelet/lipgloss v1.0.0 github.com/charmbracelet/log v0.4.0 github.com/charmbracelet/x/ansi v0.5.2 + github.com/charmbracelet/x/editor v0.1.0 github.com/charmbracelet/x/term v0.2.1 github.com/muesli/reflow v0.3.0 github.com/muesli/roff v0.1.0 @@ -24,8 +24,6 @@ require ( github.com/atotto/clipboard v0.1.4 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymerick/douceur v0.2.0 // indirect - github.com/catppuccin/go v0.2.0 // indirect - github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 // indirect github.com/dlclark/regexp2 v1.11.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect @@ -36,7 +34,6 @@ require ( github.com/mattn/go-localereader v0.0.1 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect github.com/microcosm-cc/bluemonday v1.0.27 // indirect - github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect github.com/muesli/cancelreader v0.2.2 // indirect github.com/muesli/mango v0.2.0 // indirect diff --git a/go.sum b/go.sum index 5e8a0a4..7e88dbf 100644 --- a/go.sum +++ b/go.sum @@ -18,26 +18,22 @@ github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWp github.com/aymanbagabas/go-udiff v0.2.0/go.mod h1:RE4Ex0qsGkTAJoQdQQCA0uG+nAzJO/pI/QwceO5fgrA= github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= -github.com/catppuccin/go v0.2.0 h1:ktBeIrIP42b/8FGiScP9sgrWOss3lw0Z5SktRoithGA= -github.com/catppuccin/go v0.2.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc= github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE= github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU= github.com/charmbracelet/bubbletea v1.2.4 h1:KN8aCViA0eps9SCOThb2/XPIlea3ANJLUkv3KnQRNCE= github.com/charmbracelet/bubbletea v1.2.4/go.mod h1:Qr6fVQw+wX7JkWWkVyXYk/ZUQ92a6XNekLXa3rR18MM= github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= -github.com/charmbracelet/huh v0.6.1-0.20241125235914-50e7b0ecd1da h1:q3WNIaHjiKcE3NrTeRfoQngMTvTUezIau0iF3T1sE4A= -github.com/charmbracelet/huh v0.6.1-0.20241125235914-50e7b0ecd1da/go.mod h1:zBQ8egHPGjAW+/mEDhuBq25FRmd+R6bLTDPqLMvyH7s= github.com/charmbracelet/lipgloss v1.0.0 h1:O7VkGDvqEdGi93X+DeqsQ7PKHDgtQfF8j8/O2qFMQNg= github.com/charmbracelet/lipgloss v1.0.0/go.mod h1:U5fy9Z+C38obMs+T+tJqst9VGzlOYGj4ri9reL3qUlo= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= github.com/charmbracelet/x/ansi v0.5.2 h1:dEa1x2qdOZXD/6439s+wF7xjV+kZLu/iN00GuXXrU9E= github.com/charmbracelet/x/ansi v0.5.2/go.mod h1:KBUFw1la39nl0dLl10l5ORDAqGXaeurTQmwyyVKse/Q= +github.com/charmbracelet/x/editor v0.1.0 h1:p69/dpvlwRTs9uYiPeAWruwsHqTFzHhTvQOd/WVSX98= +github.com/charmbracelet/x/editor v0.1.0/go.mod h1:oivrEbcP/AYt/Hpvk5pwDXXrQ933gQS6UzL6fxqAGSA= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= -github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 h1:qko3AQ4gK1MTS/de7F5hPGx6/k1u0w4TeYmBFwzYVP4= -github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0/go.mod h1:pBhA0ybfXv6hDjQUZ7hk1lVxBiUbupdw5R31yPUViVQ= github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ= github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -67,8 +63,6 @@ github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6T github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk= github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA= -github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4= -github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE= github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI= github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo= github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA= diff --git a/input/command.go b/input/command.go index d35515e..9ce22ca 100644 --- a/input/command.go +++ b/input/command.go @@ -4,11 +4,11 @@ import ( "fmt" "os" - "github.com/charmbracelet/bubbles/key" + "github.com/charmbracelet/bubbles/help" + "github.com/charmbracelet/bubbles/textinput" tea "github.com/charmbracelet/bubbletea" - "github.com/charmbracelet/huh" - "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/gum/cursor" "github.com/charmbracelet/gum/internal/exit" "github.com/charmbracelet/gum/internal/stdin" ) @@ -16,52 +16,58 @@ import ( // Run provides a shell script interface for the text input bubble. // https://github.com/charmbracelet/bubbles/textinput func (o Options) Run() error { - var value string + if o.Value == "" { + if in, _ := stdin.Read(); in != "" { + o.Value = in + } + } + + i := textinput.New() if o.Value != "" { - value = o.Value + i.SetValue(o.Value) } else if in, _ := stdin.Read(); in != "" { - value = in + i.SetValue(in) } + i.Focus() + i.Prompt = o.Prompt + i.Placeholder = o.Placeholder + i.Width = o.Width + i.PromptStyle = o.PromptStyle.ToLipgloss() + i.PlaceholderStyle = o.PlaceholderStyle.ToLipgloss() + i.Cursor.Style = o.CursorStyle.ToLipgloss() + i.Cursor.SetMode(cursor.Modes[o.CursorMode]) + i.CharLimit = o.CharLimit - theme := huh.ThemeCharm() - theme.Focused.Base = lipgloss.NewStyle() - theme.Focused.TextInput.Cursor = o.CursorStyle.ToLipgloss() - theme.Focused.TextInput.Placeholder = o.PlaceholderStyle.ToLipgloss() - theme.Focused.TextInput.Prompt = o.PromptStyle.ToLipgloss() - theme.Focused.Title = o.HeaderStyle.ToLipgloss() - - // Keep input keymap backwards compatible - keymap := huh.NewDefaultKeyMap() - keymap.Quit = key.NewBinding(key.WithKeys("ctrl+c", "esc")) - - echoMode := huh.EchoModeNormal if o.Password { - echoMode = huh.EchoModePassword + i.EchoMode = textinput.EchoPassword + i.EchoCharacter = '•' } - err := huh.NewForm( - huh.NewGroup( - huh.NewInput(). - Prompt(o.Prompt). - Placeholder(o.Placeholder). - CharLimit(o.CharLimit). - EchoMode(echoMode). - Title(o.Header). - Value(&value), - ), - ). - WithShowHelp(false). - WithWidth(o.Width). - WithTheme(theme). - WithKeyMap(keymap). - WithTimeout(o.Timeout). - WithShowHelp(o.ShowHelp). - WithProgramOptions(tea.WithOutput(os.Stderr)). - Run() + p := tea.NewProgram(model{ + textinput: i, + aborted: false, + header: o.Header, + headerStyle: o.HeaderStyle.ToLipgloss(), + timeout: o.Timeout, + hasTimeout: o.Timeout > 0, + autoWidth: o.Width < 1, + showHelp: o.ShowHelp, + help: help.New(), + keymap: defaultKeymap(), + }, tea.WithOutput(os.Stderr)) + tm, err := p.Run() if err != nil { - return exit.Handle(err, o.Timeout) + return fmt.Errorf("failed to run input: %w", err) } - fmt.Println(value) + m := tm.(model) + if m.aborted { + return exit.ErrAborted + } + if m.timedOut { + return exit.ErrTimeout + } + + fmt.Println(m.textinput.Value()) return nil } diff --git a/input/input.go b/input/input.go new file mode 100644 index 0000000..cb969ed --- /dev/null +++ b/input/input.go @@ -0,0 +1,112 @@ +// Package input provides a shell script interface for the text input bubble. +// https://github.com/charmbracelet/bubbles/tree/master/textinput +// +// It can be used to prompt the user for some input. The text the user entered +// will be sent to stdout. +// +// $ gum input --placeholder "What's your favorite gum?" > answer.text +package input + +import ( + "time" + + "github.com/charmbracelet/bubbles/help" + "github.com/charmbracelet/bubbles/key" + "github.com/charmbracelet/bubbles/textinput" + tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/gum/timeout" + "github.com/charmbracelet/lipgloss" +) + +type keymap textinput.KeyMap + +func defaultKeymap() keymap { + k := textinput.DefaultKeyMap + return keymap(k) +} + +// FullHelp implements help.KeyMap. +func (k keymap) FullHelp() [][]key.Binding { return nil } + +// ShortHelp implements help.KeyMap. +func (k keymap) ShortHelp() []key.Binding { + return []key.Binding{ + key.NewBinding( + key.WithKeys("enter"), + key.WithHelp("enter", "submit"), + ), + } +} + +type model struct { + autoWidth bool + header string + headerStyle lipgloss.Style + textinput textinput.Model + quitting bool + timedOut bool + aborted bool + timeout time.Duration + hasTimeout bool + showHelp bool + help help.Model + keymap keymap +} + +func (m model) Init() tea.Cmd { + return tea.Batch( + textinput.Blink, + timeout.Init(m.timeout, nil), + ) +} + +func (m model) View() string { + if m.quitting { + return "" + } + if m.header != "" { + header := m.headerStyle.Render(m.header) + return lipgloss.JoinVertical(lipgloss.Left, header, m.textinput.View()) + } + + if !m.showHelp { + return m.textinput.View() + } + return lipgloss.JoinVertical( + lipgloss.Top, + m.textinput.View(), + "", + m.help.View(m.keymap), + ) +} + +func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { + switch msg := msg.(type) { + case timeout.TickTimeoutMsg: + if msg.TimeoutValue <= 0 { + m.quitting = true + m.timedOut = true + return m, tea.Quit + } + m.timeout = msg.TimeoutValue + return m, timeout.Tick(msg.TimeoutValue, msg.Data) + case tea.WindowSizeMsg: + if m.autoWidth { + m.textinput.Width = msg.Width - lipgloss.Width(m.textinput.Prompt) - 1 + } + case tea.KeyMsg: + switch msg.String() { + case "ctrl+c", "esc": + m.quitting = true + m.aborted = true + return m, tea.Quit + case "enter": + m.quitting = true + return m, tea.Quit + } + } + + var cmd tea.Cmd + m.textinput, cmd = m.textinput.Update(msg) + return m, cmd +} diff --git a/input/options.go b/input/options.go index a89b0e0..2df85e7 100644 --- a/input/options.go +++ b/input/options.go @@ -18,7 +18,7 @@ type Options struct { CharLimit int `help:"Maximum value length (0 for no limit)" default:"400"` Width int `help:"Input width (0 for terminal width)" default:"0" env:"GUM_INPUT_WIDTH"` Password bool `help:"Mask input characters" default:"false"` - ShowHelp bool `help:"Show help keybinds" default:"true" negatable:"true" env:"GUM_INPUT_SHOW_HELP"` + ShowHelp bool `help:"Show help keybinds" default:"true" negatable:"" env:"GUM_INPUT_SHOW_HELP"` Header string `help:"Header value" default:"" env:"GUM_INPUT_HEADER"` HeaderStyle style.Styles `embed:"" prefix:"header." set:"defaultForeground=240" envprefix:"GUM_INPUT_HEADER_"` Timeout time.Duration `help:"Timeout until input aborts" default:"0s" env:"GUM_INPUT_TIMEOUT"` diff --git a/internal/exit/exit.go b/internal/exit/exit.go index e79d7c2..fb99b73 100644 --- a/internal/exit/exit.go +++ b/internal/exit/exit.go @@ -2,10 +2,7 @@ package exit import ( "errors" - "fmt" - "time" - - "github.com/charmbracelet/huh" + "strconv" ) // StatusTimeout is the exit code for timed out commands. @@ -15,12 +12,13 @@ const StatusTimeout = 124 const StatusAborted = 130 // ErrAborted is the error to return when a gum command is aborted by Ctrl+C. -var ErrAborted = huh.ErrUserAborted +var ErrAborted = errors.New("user aborted") -// Handle handles the error. -func Handle(err error, d time.Duration) error { - if errors.Is(err, huh.ErrTimeout) { - return fmt.Errorf("%w after %s", huh.ErrTimeout, d) - } - return err -} +// ErrTimeout is the error returned when the timeout is reached. +var ErrTimeout = errors.New("timeout") + +// ErrExit is a custom exit error. +type ErrExit int + +// Error implements error. +func (e ErrExit) Error() string { return "exit " + strconv.Itoa(int(e)) } diff --git a/main.go b/main.go index 301baef..fd872ed 100644 --- a/main.go +++ b/main.go @@ -7,7 +7,6 @@ import ( "runtime/debug" "github.com/alecthomas/kong" - "github.com/charmbracelet/huh" "github.com/charmbracelet/lipgloss" "github.com/muesli/termenv" @@ -73,11 +72,15 @@ func main() { }, ) if err := ctx.Run(); err != nil { - if errors.Is(err, huh.ErrTimeout) { + var ex exit.ErrExit + if errors.As(err, &ex) { + os.Exit(int(ex)) + } + if errors.Is(err, exit.ErrTimeout) { fmt.Fprintln(os.Stderr, err) os.Exit(exit.StatusTimeout) } - if errors.Is(err, huh.ErrUserAborted) { + if errors.Is(err, exit.ErrAborted) { os.Exit(exit.StatusAborted) } fmt.Fprintln(os.Stderr, err) diff --git a/pager/command.go b/pager/command.go index 5131b96..1bdf153 100644 --- a/pager/command.go +++ b/pager/command.go @@ -6,6 +6,7 @@ import ( "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/gum/internal/exit" "github.com/charmbracelet/gum/internal/stdin" ) @@ -29,7 +30,7 @@ func (o Options) Run() error { } } - model := model{ + tm, err := tea.NewProgram(model{ viewport: vp, helpStyle: o.HelpStyle.ToLipgloss(), content: o.Content, @@ -41,10 +42,15 @@ func (o Options) Run() error { matchHighlightStyle: o.MatchHighlightStyle.ToLipgloss(), timeout: o.Timeout, hasTimeout: o.Timeout > 0, - } - _, err := tea.NewProgram(model, tea.WithAltScreen()).Run() + }, tea.WithAltScreen()).Run() if err != nil { return fmt.Errorf("unable to start program: %w", err) } + + m := tm.(model) + if m.timedOut { + return exit.ErrTimeout + } + return nil } diff --git a/pager/pager.go b/pager/pager.go index f55201b..38e88d3 100644 --- a/pager/pager.go +++ b/pager/pager.go @@ -30,6 +30,7 @@ type model struct { maxWidth int timeout time.Duration hasTimeout bool + timedOut bool } func (m model) Init() tea.Cmd { @@ -40,6 +41,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case timeout.TickTimeoutMsg: if msg.TimeoutValue <= 0 { + m.timedOut = true return m, tea.Quit } m.timeout = msg.TimeoutValue diff --git a/spin/command.go b/spin/command.go index 6bde58d..a706c40 100644 --- a/spin/command.go +++ b/spin/command.go @@ -19,7 +19,7 @@ func (o Options) Run() error { s := spinner.New() s.Style = o.SpinnerStyle.ToLipgloss() s.Spinner = spinnerMap[o.Spinner] - m := model{ + tm, err := tea.NewProgram(model{ spinner: s, title: o.TitleStyle.ToLipgloss().Render(o.Title), command: o.Command, @@ -28,18 +28,18 @@ func (o Options) Run() error { showError: o.ShowError, timeout: o.Timeout, hasTimeout: o.Timeout > 0, - } - p := tea.NewProgram(m, tea.WithOutput(os.Stderr)) - mm, err := p.Run() - m = mm.(model) - + }, tea.WithOutput(os.Stderr)).Run() if err != nil { return fmt.Errorf("failed to run spin: %w", err) } + m := tm.(model) if m.aborted { return exit.ErrAborted } + if m.timedOut { + return exit.ErrTimeout + } // If the command succeeds, and we are printing output and we are in a TTY then push the STDOUT we got to the actual // STDOUT for piping or other things. @@ -64,6 +64,5 @@ func (o Options) Run() error { } } - os.Exit(m.status) - return nil + return exit.ErrExit(m.status) } diff --git a/spin/spin.go b/spin/spin.go index 9037cb0..30fd95d 100644 --- a/spin/spin.go +++ b/spin/spin.go @@ -22,7 +22,6 @@ import ( "syscall" "time" - "github.com/charmbracelet/gum/internal/exit" "github.com/charmbracelet/gum/timeout" "github.com/charmbracelet/x/term" @@ -37,6 +36,7 @@ type model struct { command []string quitting bool aborted bool + timedOut bool status int stdout string stderr string @@ -134,8 +134,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if msg.TimeoutValue <= 0 { // grab current output before closing for piped instances m.stdout = outbuf.String() - - m.status = exit.StatusAborted + m.timedOut = true return m, tea.Quit } m.timeout = msg.TimeoutValue diff --git a/write/command.go b/write/command.go index d07e2e7..97a806f 100644 --- a/write/command.go +++ b/write/command.go @@ -2,10 +2,16 @@ package write import ( "fmt" + "os" "strings" + "github.com/charmbracelet/bubbles/help" + "github.com/charmbracelet/bubbles/textarea" + tea "github.com/charmbracelet/bubbletea" + + "github.com/charmbracelet/gum/cursor" + "github.com/charmbracelet/gum/internal/exit" "github.com/charmbracelet/gum/internal/stdin" - "github.com/charmbracelet/huh" ) // Run provides a shell script interface for the text area bubble. @@ -16,39 +22,51 @@ func (o Options) Run() error { o.Value = strings.ReplaceAll(in, "\r", "") } - var value = o.Value + a := textarea.New() + a.Focus() - theme := huh.ThemeCharm() - theme.Focused.Base = o.BaseStyle.ToLipgloss() - theme.Focused.TextInput.Cursor = o.CursorStyle.ToLipgloss() - theme.Focused.Title = o.HeaderStyle.ToLipgloss() - theme.Focused.TextInput.Placeholder = o.PlaceholderStyle.ToLipgloss() - theme.Focused.TextInput.Prompt = o.PromptStyle.ToLipgloss() + a.Prompt = o.Prompt + a.Placeholder = o.Placeholder + a.ShowLineNumbers = o.ShowLineNumbers + a.CharLimit = o.CharLimit - keymap := huh.NewDefaultKeyMap() - keymap.Text.NewLine.SetHelp("ctrl+j", "new line") - - err := huh.NewForm( - huh.NewGroup( - huh.NewText(). - Title(o.Header). - Placeholder(o.Placeholder). - CharLimit(o.CharLimit). - ShowLineNumbers(o.ShowLineNumbers). - Value(&value), - ), - ). - WithWidth(o.Width). - WithHeight(o.Height). - WithTheme(theme). - WithKeyMap(keymap). - WithShowHelp(o.ShowHelp). - Run() - - if err != nil { - return err + style := textarea.Style{ + Base: o.BaseStyle.ToLipgloss(), + Placeholder: o.PlaceholderStyle.ToLipgloss(), + CursorLine: o.CursorLineStyle.ToLipgloss(), + CursorLineNumber: o.CursorLineNumberStyle.ToLipgloss(), + EndOfBuffer: o.EndOfBufferStyle.ToLipgloss(), + LineNumber: o.LineNumberStyle.ToLipgloss(), + Prompt: o.PromptStyle.ToLipgloss(), } - fmt.Println(value) + a.BlurredStyle = style + a.FocusedStyle = style + a.Cursor.Style = o.CursorStyle.ToLipgloss() + a.Cursor.SetMode(cursor.Modes[o.CursorMode]) + + a.SetWidth(o.Width) + a.SetHeight(o.Height) + a.SetValue(o.Value) + + p := tea.NewProgram(model{ + textarea: a, + header: o.Header, + headerStyle: o.HeaderStyle.ToLipgloss(), + autoWidth: o.Width < 1, + help: help.New(), + showHelp: o.ShowHelp, + keymap: defaultKeymap(), + }, tea.WithOutput(os.Stderr), tea.WithReportFocus()) + tm, err := p.Run() + if err != nil { + return fmt.Errorf("failed to run write: %w", err) + } + m := tm.(model) + if m.aborted { + return exit.ErrAborted + } + + fmt.Println(m.textarea.Value()) return nil } diff --git a/write/options.go b/write/options.go index 91b6596..0e33cd5 100644 --- a/write/options.go +++ b/write/options.go @@ -16,14 +16,13 @@ type Options struct { ShowHelp bool `help:"Show help key binds" negatable:"" default:"true" env:"GUM_WRITE_SHOW_HELP"` CursorMode string `prefix:"cursor." name:"mode" help:"Cursor mode" default:"blink" enum:"blink,hide,static" env:"GUM_WRITE_CURSOR_MODE"` - BaseStyle style.Styles `embed:"" prefix:"base." envprefix:"GUM_WRITE_BASE_"` - CursorStyle style.Styles `embed:"" prefix:"cursor." set:"defaultForeground=212" envprefix:"GUM_WRITE_CURSOR_"` - HeaderStyle style.Styles `embed:"" prefix:"header." set:"defaultForeground=240" envprefix:"GUM_WRITE_HEADER_"` - PlaceholderStyle style.Styles `embed:"" prefix:"placeholder." set:"defaultForeground=240" envprefix:"GUM_WRITE_PLACEHOLDER_"` - PromptStyle style.Styles `embed:"" prefix:"prompt." set:"defaultForeground=7" envprefix:"GUM_WRITE_PROMPT_"` - - EndOfBufferStyle style.Styles `embed:"" prefix:"end-of-buffer." set:"defaultForeground=0" envprefix:"GUM_WRITE_END_OF_BUFFER_"` - LineNumberStyle style.Styles `embed:"" prefix:"line-number." set:"defaultForeground=7" envprefix:"GUM_WRITE_LINE_NUMBER_"` + BaseStyle style.Styles `embed:"" prefix:"base." envprefix:"GUM_WRITE_BASE_"` CursorLineNumberStyle style.Styles `embed:"" prefix:"cursor-line-number." set:"defaultForeground=7" envprefix:"GUM_WRITE_CURSOR_LINE_NUMBER_"` CursorLineStyle style.Styles `embed:"" prefix:"cursor-line." envprefix:"GUM_WRITE_CURSOR_LINE_"` + CursorStyle style.Styles `embed:"" prefix:"cursor." set:"defaultForeground=212" envprefix:"GUM_WRITE_CURSOR_"` + EndOfBufferStyle style.Styles `embed:"" prefix:"end-of-buffer." set:"defaultForeground=0" envprefix:"GUM_WRITE_END_OF_BUFFER_"` + LineNumberStyle style.Styles `embed:"" prefix:"line-number." set:"defaultForeground=7" envprefix:"GUM_WRITE_LINE_NUMBER_"` + HeaderStyle style.Styles `embed:"" prefix:"header." set:"defaultForeground=240" envprefix:"GUM_WRITE_HEADER_"` + PlaceholderStyle style.Styles `embed:"" prefix:"placeholder." set:"defaultForeground=240" envprefix:"GUM_WRITE_PLACEHOLDER_"` + PromptStyle style.Styles `embed:"" prefix:"prompt." set:"defaultForeground=7" envprefix:"GUM_WRITE_PROMPT_"` } diff --git a/write/write.go b/write/write.go new file mode 100644 index 0000000..4b24234 --- /dev/null +++ b/write/write.go @@ -0,0 +1,189 @@ +// Package write provides a shell script interface for the text area bubble. +// https://github.com/charmbracelet/bubbles/tree/master/textarea +// +// It can be used to ask the user to write some long form of text (multi-line) +// input. The text the user entered will be sent to stdout. +// Text entry is completed with CTRL+D and aborted with CTRL+C or Escape. +// +// $ gum write > output.text +package write + +import ( + "io" + "os" + + "github.com/charmbracelet/bubbles/help" + "github.com/charmbracelet/bubbles/key" + "github.com/charmbracelet/bubbles/textarea" + tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/x/editor" +) + +type keymap struct { + textarea.KeyMap + Submit key.Binding + Quit key.Binding + OpenInEditor key.Binding +} + +// FullHelp implements help.KeyMap. +func (k keymap) FullHelp() [][]key.Binding { return nil } + +// ShortHelp implements help.KeyMap. +func (k keymap) ShortHelp() []key.Binding { + return []key.Binding{ + k.InsertNewline, + k.OpenInEditor, + k.Submit, + } +} + +func defaultKeymap() keymap { + km := textarea.DefaultKeyMap + km.InsertNewline = key.NewBinding( + key.WithKeys("ctrl+j"), + key.WithHelp("ctrl+j", "insert newline"), + ) + return keymap{ + KeyMap: km, + Quit: key.NewBinding( + key.WithKeys("ctrl+c"), + key.WithHelp("ctrl+c", "cancel"), + ), + OpenInEditor: key.NewBinding( + key.WithKeys("ctrl+e"), + key.WithHelp("ctrl+e", "open editor"), + ), + Submit: key.NewBinding( + key.WithKeys("enter"), + key.WithHelp("enter", "submit"), + ), + } +} + +type model struct { + autoWidth bool + aborted bool + header string + headerStyle lipgloss.Style + quitting bool + textarea textarea.Model + showHelp bool + help help.Model + keymap keymap +} + +func (m model) Init() tea.Cmd { return textarea.Blink } +func (m model) View() string { + if m.quitting { + return "" + } + + var parts []string + + // Display the header above the text area if it is not empty. + if m.header != "" { + parts = append(parts, m.headerStyle.Render(m.header)) + } + parts = append(parts, m.textarea.View()) + if m.showHelp { + parts = append(parts, m.help.View(m.keymap)) + } + return lipgloss.JoinVertical(lipgloss.Left, parts...) +} + +func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { + switch msg := msg.(type) { + case tea.WindowSizeMsg: + if m.autoWidth { + m.textarea.SetWidth(msg.Width) + } + case tea.FocusMsg, tea.BlurMsg: + var cmd tea.Cmd + m.textarea, cmd = m.textarea.Update(msg) + return m, cmd + case startEditorMsg: + return m, openEditor(msg.path, msg.lineno) + case editorFinishedMsg: + if msg.err != nil { + m.aborted = true + m.quitting = true + return m, tea.Quit + } + m.textarea.SetValue(msg.content) + case tea.KeyMsg: + km := m.keymap + switch { + case key.Matches(msg, km.Quit): + m.aborted = true + m.quitting = true + return m, tea.Quit + case key.Matches(msg, km.Submit): + m.quitting = true + return m, tea.Quit + case key.Matches(msg, km.OpenInEditor): + //nolint: gosec + return m, createTempFile(m.textarea.Value(), uint(m.textarea.Line())+1) + } + } + + var cmd tea.Cmd + m.textarea, cmd = m.textarea.Update(msg) + return m, cmd +} + +type startEditorMsg struct { + path string + lineno uint +} + +type editorFinishedMsg struct { + content string + err error +} + +func createTempFile(content string, lineno uint) tea.Cmd { + return func() tea.Msg { + f, err := os.CreateTemp("", "gum.*.md") + if err != nil { + return editorFinishedMsg{err: err} + } + _, err = io.WriteString(f, content) + if err != nil { + return editorFinishedMsg{err: err} + } + _ = f.Close() + return startEditorMsg{ + path: f.Name(), + lineno: lineno, + } + } +} + +func openEditor(path string, lineno uint) tea.Cmd { + cb := func(err error) tea.Msg { + if err != nil { + return editorFinishedMsg{ + err: err, + } + } + bts, err := os.ReadFile(path) + if err != nil { + return editorFinishedMsg{err: err} + } + return editorFinishedMsg{ + content: string(bts), + } + } + cmd, err := editor.Cmd( + "Gum", + path, + editor.LineNumber(lineno), + editor.EndOfLine(), + ) + if err != nil { + return func() tea.Msg { return cb(err) } + } + return tea.ExecProcess(cmd, cb) +} From 4f469522d5c372d5a5f2a0f30552c0244f8cda46 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 9 Dec 2024 14:30:35 -0300 Subject: [PATCH 068/198] feat: handle interrupts and timeouts (#747) --- choose/choose.go | 34 ++++---------------------- choose/command.go | 32 ++++++++++++------------- confirm/command.go | 28 +++++++++++----------- confirm/confirm.go | 43 ++++++--------------------------- file/command.go | 20 +++++++--------- file/file.go | 25 ++----------------- filter/command.go | 25 +++++++++---------- filter/filter.go | 23 ++---------------- go.mod | 6 ++--- go.sum | 12 +++++----- input/command.go | 28 ++++++++++------------ input/input.go | 29 ++++------------------ internal/exit/exit.go | 7 ------ internal/timeout/context.go | 15 ++++++++++++ main.go | 10 ++++---- pager/command.go | 22 +++++++++-------- pager/pager.go | 31 ++++++------------------ spin/command.go | 30 +++++++++++------------ spin/spin.go | 30 ++++------------------- table/command.go | 16 +++++++++---- table/options.go | 17 ++++++++----- table/table.go | 9 +++---- timeout/options.go | 48 ------------------------------------- write/command.go | 23 +++++++++++------- write/options.go | 29 ++++++++++++---------- write/write.go | 14 +++++------ 26 files changed, 214 insertions(+), 392 deletions(-) create mode 100644 internal/timeout/context.go delete mode 100644 timeout/options.go diff --git a/choose/choose.go b/choose/choose.go index 42eae17..2c2e117 100644 --- a/choose/choose.go +++ b/choose/choose.go @@ -12,13 +12,11 @@ package choose import ( "strings" - "time" "github.com/charmbracelet/bubbles/help" "github.com/charmbracelet/bubbles/key" "github.com/charmbracelet/bubbles/paginator" tea "github.com/charmbracelet/bubbletea" - "github.com/charmbracelet/gum/timeout" "github.com/charmbracelet/lipgloss" ) @@ -112,8 +110,6 @@ type model struct { numSelected int currentOrder int paginator paginator.Model - aborted bool - timedOut bool showHelp bool help help.Model keymap keymap @@ -123,8 +119,6 @@ type model struct { headerStyle lipgloss.Style itemStyle lipgloss.Style selectedItemStyle lipgloss.Style - hasTimeout bool - timeout time.Duration } type item struct { @@ -133,28 +127,13 @@ type item struct { order int } -func (m model) Init() tea.Cmd { - return timeout.Init(m.timeout, nil) -} +func (m model) Init() tea.Cmd { return nil } func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case tea.WindowSizeMsg: return m, nil - case timeout.TickTimeoutMsg: - if msg.TimeoutValue <= 0 { - m.quitting = true - m.timedOut = true - // 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 - } - m.timeout = msg.TimeoutValue - return m, timeout.Tick(msg.TimeoutValue, msg.Data) + case tea.KeyMsg: start, end := m.paginator.GetSliceBounds(len(m.items)) km := m.keymap @@ -199,9 +178,8 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m = m.deselectAll() } case key.Matches(msg, km.Abort): - m.aborted = true m.quitting = true - return m, tea.Quit + return m, tea.Interrupt case key.Matches(msg, km.Toggle): if m.limit == 1 { break // no op @@ -262,7 +240,6 @@ func (m model) View() string { } var s strings.Builder - var timeoutStr string start, end := m.paginator.GetSliceBounds(len(m.items)) for i, item := range m.items[start:end] { @@ -273,10 +250,7 @@ func (m model) View() string { } if item.selected { - if m.hasTimeout { - timeoutStr = timeout.Str(m.timeout) - } - s.WriteString(m.selectedItemStyle.Render(m.selectedPrefix + item.text + timeoutStr)) + s.WriteString(m.selectedItemStyle.Render(m.selectedPrefix + item.text)) } else if i == m.index%m.height { s.WriteString(m.cursorStyle.Render(m.cursorPrefix + item.text)) } else { diff --git a/choose/command.go b/choose/command.go index 26e6e23..bcd052b 100644 --- a/choose/command.go +++ b/choose/command.go @@ -11,12 +11,11 @@ import ( "github.com/charmbracelet/bubbles/help" "github.com/charmbracelet/bubbles/paginator" tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/gum/internal/stdin" + "github.com/charmbracelet/gum/internal/timeout" "github.com/charmbracelet/lipgloss" "github.com/charmbracelet/x/ansi" "github.com/charmbracelet/x/term" - - "github.com/charmbracelet/gum/internal/exit" - "github.com/charmbracelet/gum/internal/stdin" ) // Run provides a shell script interface for choosing between different through @@ -102,8 +101,7 @@ func (o Options) Run() error { km.ToggleAll.SetEnabled(true) } - // Disable Keybindings since we will control it ourselves. - tm, err := tea.NewProgram(model{ + m := model{ index: startingIndex, currentOrder: currentOrder, height: o.Height, @@ -120,22 +118,24 @@ func (o Options) Run() error { itemStyle: o.ItemStyle.ToLipgloss(), selectedItemStyle: o.SelectedItemStyle.ToLipgloss(), numSelected: currentSelected, - hasTimeout: o.Timeout > 0, - timeout: o.Timeout, showHelp: o.ShowHelp, help: help.New(), keymap: km, - }, tea.WithOutput(os.Stderr)).Run() + } + + ctx, cancel := timeout.Context(o.Timeout) + defer cancel() + + // Disable Keybindings since we will control it ourselves. + tm, err := tea.NewProgram( + m, + tea.WithOutput(os.Stderr), + tea.WithContext(ctx), + ).Run() if err != nil { - return fmt.Errorf("failed to start tea program: %w", err) - } - m := tm.(model) - if m.aborted { - return exit.ErrAborted - } - if m.timedOut { - return exit.ErrTimeout + return fmt.Errorf("unable to pick selection: %w", err) } + m = tm.(model) if o.Ordered && o.Limit > 1 { sort.Slice(m.items, func(i, j int) bool { return m.items[i].order < m.items[j].order diff --git a/confirm/command.go b/confirm/command.go index e31dd9f..2e83f6d 100644 --- a/confirm/command.go +++ b/confirm/command.go @@ -2,24 +2,25 @@ package confirm import ( "errors" + "fmt" "os" "github.com/charmbracelet/bubbles/help" - "github.com/charmbracelet/gum/internal/exit" - tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/gum/internal/timeout" ) // Run provides a shell script interface for prompting a user to confirm an // action with an affirmative or negative answer. func (o Options) Run() error { - tm, err := tea.NewProgram(model{ + ctx, cancel := timeout.Context(o.Timeout) + defer cancel() + + m := model{ affirmative: o.Affirmative, negative: o.Negative, confirmation: o.Default, defaultSelection: o.Default, - timeout: o.Timeout, - hasTimeout: o.Timeout > 0, keys: defaultKeymap(o.Affirmative, o.Negative), help: help.New(), showHelp: o.ShowHelp, @@ -27,18 +28,17 @@ func (o Options) Run() error { selectedStyle: o.SelectedStyle.ToLipgloss(), unselectedStyle: o.UnselectedStyle.ToLipgloss(), promptStyle: o.PromptStyle.ToLipgloss(), - }, tea.WithOutput(os.Stderr)).Run() + } + tm, err := tea.NewProgram( + m, + tea.WithOutput(os.Stderr), + tea.WithContext(ctx), + ).Run() if err != nil { - return err + return fmt.Errorf("unable to confirm: %w", err) } - m := tm.(model) - if m.timedOut { - return exit.ErrTimeout - } - if m.aborted { - return exit.ErrAborted - } + m = tm.(model) if m.confirmation { return nil } diff --git a/confirm/confirm.go b/confirm/confirm.go index c258068..95d911c 100644 --- a/confirm/confirm.go +++ b/confirm/confirm.go @@ -11,11 +11,8 @@ package confirm import ( - "time" - "github.com/charmbracelet/bubbles/help" "github.com/charmbracelet/bubbles/key" - "github.com/charmbracelet/gum/timeout" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" @@ -81,15 +78,11 @@ type model struct { affirmative string negative string quitting bool - aborted bool - hasTimeout bool showHelp bool help help.Model keys keymap - timeout time.Duration confirmation bool - timedOut bool defaultSelection bool @@ -99,9 +92,7 @@ type model struct { unselectedStyle lipgloss.Style } -func (m model) Init() tea.Cmd { - return timeout.Init(m.timeout, m.defaultSelection) -} +func (m model) Init() tea.Cmd { return nil } func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { @@ -111,8 +102,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch { case key.Matches(msg, m.keys.Abort): m.confirmation = false - m.aborted = true - fallthrough + return m, tea.Interrupt case key.Matches(msg, m.keys.Quit): m.confirmation = false m.quitting = true @@ -134,16 +124,6 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.confirmation = true return m, tea.Quit } - case timeout.TickTimeoutMsg: - if msg.TimeoutValue <= 0 { - m.quitting = true - m.confirmation = m.defaultSelection - m.timedOut = true - return m, tea.Quit - } - - m.timeout = msg.TimeoutValue - return m, timeout.Tick(msg.TimeoutValue, msg.Data) } return m, nil } @@ -153,23 +133,14 @@ func (m model) View() string { return "" } - var aff, neg, timeoutStrYes, timeoutStrNo string - timeoutStrNo = "" - timeoutStrYes = "" - if m.hasTimeout { - if m.defaultSelection { - timeoutStrYes = timeout.Str(m.timeout) - } else { - timeoutStrNo = timeout.Str(m.timeout) - } - } + var aff, neg string if m.confirmation { - aff = m.selectedStyle.Render(m.affirmative + timeoutStrYes) - neg = m.unselectedStyle.Render(m.negative + timeoutStrNo) + aff = m.selectedStyle.Render(m.affirmative) + neg = m.unselectedStyle.Render(m.negative) } else { - aff = m.unselectedStyle.Render(m.affirmative + timeoutStrYes) - neg = m.selectedStyle.Render(m.negative + timeoutStrNo) + aff = m.unselectedStyle.Render(m.affirmative) + neg = m.selectedStyle.Render(m.negative) } // If the option is intentionally empty, do not show it. diff --git a/file/command.go b/file/command.go index 6c6d26e..28ef0aa 100644 --- a/file/command.go +++ b/file/command.go @@ -9,7 +9,7 @@ import ( "github.com/charmbracelet/bubbles/filepicker" "github.com/charmbracelet/bubbles/help" tea "github.com/charmbracelet/bubbletea" - "github.com/charmbracelet/gum/internal/exit" + "github.com/charmbracelet/gum/internal/timeout" ) // Run is the interface to picking a file. @@ -48,25 +48,23 @@ func (o Options) Run() error { fp.Styles.FileSize = o.FileSizeStyle.ToLipgloss() m := model{ filepicker: fp, - timeout: o.Timeout, - hasTimeout: o.Timeout > 0, - aborted: false, showHelp: o.ShowHelp, help: help.New(), keymap: defaultKeymap(), } - tm, err := tea.NewProgram(&m, tea.WithOutput(os.Stderr)).Run() + ctx, cancel := timeout.Context(o.Timeout) + defer cancel() + + tm, err := tea.NewProgram( + &m, + tea.WithOutput(os.Stderr), + tea.WithContext(ctx), + ).Run() if err != nil { return fmt.Errorf("unable to pick selection: %w", err) } m = tm.(model) - if m.aborted { - return exit.ErrAborted - } - if m.timedOut { - return exit.ErrTimeout - } if m.selectedPath == "" { return errors.New("no file selected") } diff --git a/file/file.go b/file/file.go index b327768..b3ddede 100644 --- a/file/file.go +++ b/file/file.go @@ -13,13 +13,10 @@ package file import ( - "time" - "github.com/charmbracelet/bubbles/filepicker" "github.com/charmbracelet/bubbles/help" "github.com/charmbracelet/bubbles/key" tea "github.com/charmbracelet/bubbletea" - "github.com/charmbracelet/gum/timeout" "github.com/charmbracelet/lipgloss" ) @@ -58,22 +55,13 @@ func (k keymap) ShortHelp() []key.Binding { type model struct { filepicker filepicker.Model selectedPath string - aborted bool - timedOut bool quitting bool - timeout time.Duration - hasTimeout bool showHelp bool help help.Model keymap keymap } -func (m model) Init() tea.Cmd { - return tea.Batch( - timeout.Init(m.timeout, nil), - m.filepicker.Init(), - ) -} +func (m model) Init() tea.Cmd { return m.filepicker.Init() } func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { @@ -84,21 +72,12 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case tea.KeyMsg: switch { case key.Matches(msg, keyAbort): - m.aborted = true m.quitting = true - return m, tea.Quit + return m, tea.Interrupt case key.Matches(msg, keyQuit): m.quitting = true return m, tea.Quit } - case timeout.TickTimeoutMsg: - if msg.TimeoutValue <= 0 { - m.quitting = true - m.timedOut = true - return m, tea.Quit - } - m.timeout = msg.TimeoutValue - return m, timeout.Tick(msg.TimeoutValue, msg.Data) } var cmd tea.Cmd m.filepicker, cmd = m.filepicker.Update(msg) diff --git a/filter/command.go b/filter/command.go index 15093ad..1264534 100644 --- a/filter/command.go +++ b/filter/command.go @@ -10,13 +10,12 @@ import ( "github.com/charmbracelet/bubbles/textinput" "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/gum/internal/files" + "github.com/charmbracelet/gum/internal/stdin" + "github.com/charmbracelet/gum/internal/timeout" "github.com/charmbracelet/x/ansi" "github.com/charmbracelet/x/term" "github.com/sahilm/fuzzy" - - "github.com/charmbracelet/gum/internal/exit" - "github.com/charmbracelet/gum/internal/files" - "github.com/charmbracelet/gum/internal/stdin" ) // Run provides a shell script interface for filtering through options, powered @@ -50,7 +49,13 @@ func (o Options) Run() error { return nil } - options := []tea.ProgramOption{tea.WithOutput(os.Stderr)} + ctx, cancel := timeout.Context(o.Timeout) + defer cancel() + + options := []tea.ProgramOption{ + tea.WithOutput(os.Stderr), + tea.WithContext(ctx), + } if o.Height == 0 { options = append(options, tea.WithAltScreen()) } @@ -100,8 +105,6 @@ func (o Options) Run() error { limit: o.Limit, reverse: o.Reverse, fuzzy: o.Fuzzy, - timeout: o.Timeout, - hasTimeout: o.Timeout > 0, sort: o.Sort && o.FuzzySort, strict: o.Strict, showHelp: o.ShowHelp, @@ -113,14 +116,8 @@ func (o Options) Run() error { if err != nil { return fmt.Errorf("unable to run filter: %w", err) } - m := tm.(model) - if m.aborted { - return exit.ErrAborted - } - if m.timedOut { - return exit.ErrTimeout - } + m := tm.(model) isTTY := term.IsTerminal(os.Stdout.Fd()) // allSelections contains values only if limit is greater diff --git a/filter/filter.go b/filter/filter.go index 956d502..576ba13 100644 --- a/filter/filter.go +++ b/filter/filter.go @@ -12,9 +12,6 @@ package filter import ( "strings" - "time" - - "github.com/charmbracelet/gum/timeout" "github.com/charmbracelet/bubbles/help" "github.com/charmbracelet/bubbles/key" @@ -100,8 +97,6 @@ type model struct { selectedPrefix string unselectedPrefix string height int - aborted bool - timedOut bool quitting bool headerStyle lipgloss.Style matchStyle lipgloss.Style @@ -116,14 +111,10 @@ type model struct { showHelp bool keymap keymap help help.Model - timeout time.Duration - hasTimeout bool strict bool } -func (m model) Init() tea.Cmd { - return timeout.Init(m.timeout, nil) -} +func (m model) Init() tea.Cmd { return nil } func (m model) View() string { if m.quitting { @@ -240,15 +231,6 @@ func (m model) helpView() string { func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { var cmd tea.Cmd switch msg := msg.(type) { - case timeout.TickTimeoutMsg: - if msg.TimeoutValue <= 0 { - m.quitting = true - m.timedOut = true - return m, tea.Quit - } - m.timeout = msg.TimeoutValue - return m, timeout.Tick(msg.TimeoutValue, msg.Data) - case tea.WindowSizeMsg: if m.height == 0 || m.height > msg.Height { m.viewport.Height = msg.Height - lipgloss.Height(m.textinput.View()) @@ -269,9 +251,8 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { km := m.keymap switch { case key.Matches(msg, km.Abort): - m.aborted = true m.quitting = true - return m, tea.Quit + return m, tea.Interrupt case key.Matches(msg, km.Submit): m.quitting = true return m, tea.Quit diff --git a/go.mod b/go.mod index 88df801..8862262 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/alecthomas/kong v1.6.0 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 - github.com/charmbracelet/bubbletea v1.2.4 + github.com/charmbracelet/bubbletea v1.2.5-0.20241207142916-e0515bc22ad1 github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/lipgloss v1.0.0 github.com/charmbracelet/log v0.4.0 @@ -42,8 +42,8 @@ require ( github.com/yuin/goldmark-emoji v1.0.4 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/net v0.27.0 // indirect - golang.org/x/sync v0.9.0 // indirect - golang.org/x/sys v0.27.0 // indirect + golang.org/x/sync v0.10.0 // indirect + golang.org/x/sys v0.28.0 // indirect golang.org/x/term v0.22.0 // indirect golang.org/x/text v0.18.0 // indirect ) diff --git a/go.sum b/go.sum index 7e88dbf..80fe2e8 100644 --- a/go.sum +++ b/go.sum @@ -20,8 +20,8 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE= github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU= -github.com/charmbracelet/bubbletea v1.2.4 h1:KN8aCViA0eps9SCOThb2/XPIlea3ANJLUkv3KnQRNCE= -github.com/charmbracelet/bubbletea v1.2.4/go.mod h1:Qr6fVQw+wX7JkWWkVyXYk/ZUQ92a6XNekLXa3rR18MM= +github.com/charmbracelet/bubbletea v1.2.5-0.20241207142916-e0515bc22ad1 h1:osd3dk14DEriOrqJBWzeDE9eN2Yd00BkKzFAiLXxkS8= +github.com/charmbracelet/bubbletea v1.2.5-0.20241207142916-e0515bc22ad1/go.mod h1:Hbk5+oE4a7cDyjfdPi4sHZ42aGTMYcmHnVDhsRswn7A= github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= github.com/charmbracelet/lipgloss v1.0.0 h1:O7VkGDvqEdGi93X+DeqsQ7PKHDgtQfF8j8/O2qFMQNg= @@ -94,12 +94,12 @@ golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0J golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= -golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= -golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= +golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= -golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= diff --git a/input/command.go b/input/command.go index 9ce22ca..5553055 100644 --- a/input/command.go +++ b/input/command.go @@ -7,10 +7,9 @@ import ( "github.com/charmbracelet/bubbles/help" "github.com/charmbracelet/bubbles/textinput" tea "github.com/charmbracelet/bubbletea" - "github.com/charmbracelet/gum/cursor" - "github.com/charmbracelet/gum/internal/exit" "github.com/charmbracelet/gum/internal/stdin" + "github.com/charmbracelet/gum/internal/timeout" ) // Run provides a shell script interface for the text input bubble. @@ -43,31 +42,30 @@ func (o Options) Run() error { i.EchoCharacter = '•' } - p := tea.NewProgram(model{ + m := model{ textinput: i, - aborted: false, header: o.Header, headerStyle: o.HeaderStyle.ToLipgloss(), - timeout: o.Timeout, - hasTimeout: o.Timeout > 0, autoWidth: o.Width < 1, showHelp: o.ShowHelp, help: help.New(), keymap: defaultKeymap(), - }, tea.WithOutput(os.Stderr)) + } + + ctx, cancel := timeout.Context(o.Timeout) + defer cancel() + + p := tea.NewProgram( + m, + tea.WithOutput(os.Stderr), + tea.WithContext(ctx), + ) tm, err := p.Run() if err != nil { return fmt.Errorf("failed to run input: %w", err) } - m := tm.(model) - if m.aborted { - return exit.ErrAborted - } - if m.timedOut { - return exit.ErrTimeout - } - + m = tm.(model) fmt.Println(m.textinput.Value()) return nil } diff --git a/input/input.go b/input/input.go index cb969ed..89b88ab 100644 --- a/input/input.go +++ b/input/input.go @@ -8,13 +8,10 @@ package input import ( - "time" - "github.com/charmbracelet/bubbles/help" "github.com/charmbracelet/bubbles/key" "github.com/charmbracelet/bubbles/textinput" tea "github.com/charmbracelet/bubbletea" - "github.com/charmbracelet/gum/timeout" "github.com/charmbracelet/lipgloss" ) @@ -44,21 +41,12 @@ type model struct { headerStyle lipgloss.Style textinput textinput.Model quitting bool - timedOut bool - aborted bool - timeout time.Duration - hasTimeout bool showHelp bool help help.Model keymap keymap } -func (m model) Init() tea.Cmd { - return tea.Batch( - textinput.Blink, - timeout.Init(m.timeout, nil), - ) -} +func (m model) Init() tea.Cmd { return textinput.Blink } func (m model) View() string { if m.quitting { @@ -82,25 +70,16 @@ func (m model) View() string { func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { - case timeout.TickTimeoutMsg: - if msg.TimeoutValue <= 0 { - m.quitting = true - m.timedOut = true - return m, tea.Quit - } - m.timeout = msg.TimeoutValue - return m, timeout.Tick(msg.TimeoutValue, msg.Data) case tea.WindowSizeMsg: if m.autoWidth { m.textinput.Width = msg.Width - lipgloss.Width(m.textinput.Prompt) - 1 } case tea.KeyMsg: switch msg.String() { - case "ctrl+c", "esc": + case "ctrl+c": m.quitting = true - m.aborted = true - return m, tea.Quit - case "enter": + return m, tea.Interrupt + case "esc", "enter": m.quitting = true return m, tea.Quit } diff --git a/internal/exit/exit.go b/internal/exit/exit.go index fb99b73..c4f3387 100644 --- a/internal/exit/exit.go +++ b/internal/exit/exit.go @@ -1,7 +1,6 @@ package exit import ( - "errors" "strconv" ) @@ -11,12 +10,6 @@ const StatusTimeout = 124 // StatusAborted is the exit code for aborted commands. const StatusAborted = 130 -// ErrAborted is the error to return when a gum command is aborted by Ctrl+C. -var ErrAborted = errors.New("user aborted") - -// ErrTimeout is the error returned when the timeout is reached. -var ErrTimeout = errors.New("timeout") - // ErrExit is a custom exit error. type ErrExit int diff --git a/internal/timeout/context.go b/internal/timeout/context.go new file mode 100644 index 0000000..99eaf34 --- /dev/null +++ b/internal/timeout/context.go @@ -0,0 +1,15 @@ +package timeout + +import ( + "context" + "time" +) + +// Context setup a new context that times out if the given timeout is > 0. +func Context(timeout time.Duration) (context.Context, context.CancelFunc) { + ctx := context.Background() + if timeout == 0 { + return ctx, func() {} + } + return context.WithTimeout(ctx, timeout) +} diff --git a/main.go b/main.go index fd872ed..75741e2 100644 --- a/main.go +++ b/main.go @@ -7,10 +7,10 @@ import ( "runtime/debug" "github.com/alecthomas/kong" + tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/gum/internal/exit" "github.com/charmbracelet/lipgloss" "github.com/muesli/termenv" - - "github.com/charmbracelet/gum/internal/exit" ) const shaLen = 7 @@ -76,11 +76,11 @@ func main() { if errors.As(err, &ex) { os.Exit(int(ex)) } - if errors.Is(err, exit.ErrTimeout) { - fmt.Fprintln(os.Stderr, err) + if errors.Is(err, tea.ErrProgramKilled) { + fmt.Fprintln(os.Stderr, "timed out") os.Exit(exit.StatusTimeout) } - if errors.Is(err, exit.ErrAborted) { + if errors.Is(err, tea.ErrInterrupted) { os.Exit(exit.StatusAborted) } fmt.Fprintln(os.Stderr, err) diff --git a/pager/command.go b/pager/command.go index 1bdf153..bf4f5be 100644 --- a/pager/command.go +++ b/pager/command.go @@ -6,8 +6,8 @@ import ( "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" - "github.com/charmbracelet/gum/internal/exit" "github.com/charmbracelet/gum/internal/stdin" + "github.com/charmbracelet/gum/internal/timeout" ) // Run provides a shell script interface for the viewport bubble. @@ -30,7 +30,7 @@ func (o Options) Run() error { } } - tm, err := tea.NewProgram(model{ + m := model{ viewport: vp, helpStyle: o.HelpStyle.ToLipgloss(), content: o.Content, @@ -40,17 +40,19 @@ func (o Options) Run() error { softWrap: o.SoftWrap, matchStyle: o.MatchStyle.ToLipgloss(), matchHighlightStyle: o.MatchHighlightStyle.ToLipgloss(), - timeout: o.Timeout, - hasTimeout: o.Timeout > 0, - }, tea.WithAltScreen()).Run() + } + + ctx, cancel := timeout.Context(o.Timeout) + defer cancel() + + _, err := tea.NewProgram( + m, + tea.WithAltScreen(), + tea.WithContext(ctx), + ).Run() if err != nil { return fmt.Errorf("unable to start program: %w", err) } - m := tm.(model) - if m.timedOut { - return exit.ErrTimeout - } - return nil } diff --git a/pager/pager.go b/pager/pager.go index 38e88d3..6ee2ce6 100644 --- a/pager/pager.go +++ b/pager/pager.go @@ -6,9 +6,6 @@ package pager import ( "fmt" "strings" - "time" - - "github.com/charmbracelet/gum/timeout" "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" @@ -28,25 +25,12 @@ type model struct { matchStyle lipgloss.Style matchHighlightStyle lipgloss.Style maxWidth int - timeout time.Duration - hasTimeout bool - timedOut bool } -func (m model) Init() tea.Cmd { - return timeout.Init(m.timeout, nil) -} +func (m model) Init() tea.Cmd { return nil } func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { - case timeout.TickTimeoutMsg: - if msg.TimeoutValue <= 0 { - m.timedOut = true - return m, tea.Quit - } - m.timeout = msg.TimeoutValue - return m, timeout.Tick(msg.TimeoutValue, msg.Data) - case tea.WindowSizeMsg: m.ProcessText(msg) case tea.KeyMsg: @@ -134,8 +118,10 @@ func (m model) KeyHandler(key tea.KeyMsg) (model, func() tea.Msg) { case "n": m.search.NextMatch(&m) m.ProcessText(tea.WindowSizeMsg{Height: m.viewport.Height + heightOffset, Width: m.viewport.Width}) - case "q", "ctrl+c", "esc": + case "q", "esc": return m, tea.Quit + case "ctrl+c": + return m, tea.Interrupt } m.viewport, cmd = m.viewport.Update(key) } @@ -144,17 +130,14 @@ func (m model) KeyHandler(key tea.KeyMsg) (model, func() tea.Msg) { } func (m model) View() string { - var timeoutStr string - if m.hasTimeout { - timeoutStr = timeout.Str(m.timeout) + " " - } - helpMsg := "\n" + timeoutStr + " ↑/↓: Navigate • q: Quit • /: Search " + // TODO: use help bubble here + helpMsg := "\n ↑/↓: Navigate • q: Quit • /: Search " if m.search.query != nil { helpMsg += "• n: Next Match " helpMsg += "• N: Prev Match " } if m.search.active { - return m.viewport.View() + "\n" + timeoutStr + " " + m.search.input.View() + return m.viewport.View() + "\n " + m.search.input.View() } return m.viewport.View() + m.helpStyle.Render(helpMsg) diff --git a/spin/command.go b/spin/command.go index a706c40..5dd04eb 100644 --- a/spin/command.go +++ b/spin/command.go @@ -6,9 +6,9 @@ import ( "github.com/charmbracelet/bubbles/spinner" tea "github.com/charmbracelet/bubbletea" - "github.com/charmbracelet/x/term" - "github.com/charmbracelet/gum/internal/exit" + "github.com/charmbracelet/gum/internal/timeout" + "github.com/charmbracelet/x/term" ) // Run provides a shell script interface for the spinner bubble. @@ -19,28 +19,28 @@ func (o Options) Run() error { s := spinner.New() s.Style = o.SpinnerStyle.ToLipgloss() s.Spinner = spinnerMap[o.Spinner] - tm, err := tea.NewProgram(model{ + m := model{ spinner: s, title: o.TitleStyle.ToLipgloss().Render(o.Title), command: o.Command, align: o.Align, showOutput: o.ShowOutput && isTTY, showError: o.ShowError, - timeout: o.Timeout, - hasTimeout: o.Timeout > 0, - }, tea.WithOutput(os.Stderr)).Run() + } + + ctx, cancel := timeout.Context(o.Timeout) + defer cancel() + + tm, err := tea.NewProgram( + m, + tea.WithOutput(os.Stderr), + tea.WithContext(ctx), + ).Run() if err != nil { - return fmt.Errorf("failed to run spin: %w", err) - } - - m := tm.(model) - if m.aborted { - return exit.ErrAborted - } - if m.timedOut { - return exit.ErrTimeout + return fmt.Errorf("unable to run action: %w", err) } + m = tm.(model) // If the command succeeds, and we are printing output and we are in a TTY then push the STDOUT we got to the actual // STDOUT for piping or other things. //nolint:nestif diff --git a/spin/spin.go b/spin/spin.go index 30fd95d..61cc7ec 100644 --- a/spin/spin.go +++ b/spin/spin.go @@ -20,13 +20,10 @@ import ( "os/exec" "strings" "syscall" - "time" - - "github.com/charmbracelet/gum/timeout" - "github.com/charmbracelet/x/term" "github.com/charmbracelet/bubbles/spinner" tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/x/term" ) type model struct { @@ -35,16 +32,12 @@ type model struct { align string command []string quitting bool - aborted bool - timedOut bool status int stdout string stderr string output string showOutput bool showError bool - timeout time.Duration - hasTimeout bool } var ( @@ -95,14 +88,13 @@ func commandAbort() tea.Msg { if executing != nil && executing.Process != nil { _ = executing.Process.Signal(syscall.SIGINT) } - return nil + return tea.InterruptMsg{} } func (m model) Init() tea.Cmd { return tea.Batch( m.spinner.Tick, commandStart(m.command), - timeout.Init(m.timeout, nil), ) } @@ -111,15 +103,11 @@ func (m model) View() string { return strings.TrimPrefix(errbuf.String()+"\n"+outbuf.String(), "\n") } - var str string - if m.hasTimeout { - str = timeout.Str(m.timeout) - } var header string if m.align == "left" { - header = m.spinner.View() + str + " " + m.title + header = m.spinner.View() + " " + m.title } else { - header = str + " " + m.title + " " + m.spinner.View() + header = m.title + " " + m.spinner.View() } if !m.showOutput { return header @@ -130,15 +118,6 @@ func (m model) View() string { func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { var cmd tea.Cmd switch msg := msg.(type) { - case timeout.TickTimeoutMsg: - if msg.TimeoutValue <= 0 { - // grab current output before closing for piped instances - m.stdout = outbuf.String() - m.timedOut = true - return m, tea.Quit - } - m.timeout = msg.TimeoutValue - return m, timeout.Tick(msg.TimeoutValue, msg.Data) case finishCommandMsg: m.stdout = msg.stdout m.stderr = msg.stderr @@ -149,7 +128,6 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case tea.KeyMsg: switch msg.String() { case "ctrl+c": - m.aborted = true return m, commandAbort } } diff --git a/table/command.go b/table/command.go index 98b5fdc..2e6f8fa 100644 --- a/table/command.go +++ b/table/command.go @@ -7,11 +7,11 @@ import ( "github.com/charmbracelet/bubbles/table" tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/gum/internal/stdin" + "github.com/charmbracelet/gum/internal/timeout" + "github.com/charmbracelet/gum/style" "github.com/charmbracelet/lipgloss" ltable "github.com/charmbracelet/lipgloss/table" - - "github.com/charmbracelet/gum/internal/stdin" - "github.com/charmbracelet/gum/style" ) // Run provides a shell script interface for rendering tabular data (CSV). @@ -111,9 +111,17 @@ func (o Options) Run() error { if o.Height > 0 { opts = append(opts, table.WithHeight(o.Height)) } + table := table.New(opts...) - tm, err := tea.NewProgram(model{table: table}, tea.WithOutput(os.Stderr)).Run() + ctx, cancel := timeout.Context(o.Timeout) + defer cancel() + + tm, err := tea.NewProgram( + model{table: table}, + tea.WithOutput(os.Stderr), + tea.WithContext(ctx), + ).Run() if err != nil { return fmt.Errorf("failed to start tea program: %w", err) } diff --git a/table/options.go b/table/options.go index fcfa579..853a8de 100644 --- a/table/options.go +++ b/table/options.go @@ -1,6 +1,10 @@ package table -import "github.com/charmbracelet/gum/style" +import ( + "time" + + "github.com/charmbracelet/gum/style" +) // Options is the customization options for the table command. type Options struct { @@ -12,9 +16,10 @@ type Options struct { File string `short:"f" help:"file path" default:""` Border string `short:"b" help:"border style" default:"rounded" enum:"rounded,thick,normal,hidden,double,none"` - BorderStyle style.Styles `embed:"" prefix:"border." envprefix:"GUM_TABLE_BORDER_"` - CellStyle style.Styles `embed:"" prefix:"cell." envprefix:"GUM_TABLE_CELL_"` - HeaderStyle style.Styles `embed:"" prefix:"header." envprefix:"GUM_TABLE_HEADER_"` - SelectedStyle style.Styles `embed:"" prefix:"selected." set:"defaultForeground=212" envprefix:"GUM_TABLE_SELECTED_"` - ReturnColumn int `short:"r" help:"Which column number should be returned instead of whole row as string. Default=0 returns whole Row" default:"0"` + BorderStyle style.Styles `embed:"" prefix:"border." envprefix:"GUM_TABLE_BORDER_"` + CellStyle style.Styles `embed:"" prefix:"cell." envprefix:"GUM_TABLE_CELL_"` + HeaderStyle style.Styles `embed:"" prefix:"header." envprefix:"GUM_TABLE_HEADER_"` + SelectedStyle style.Styles `embed:"" prefix:"selected." set:"defaultForeground=212" envprefix:"GUM_TABLE_SELECTED_"` + ReturnColumn int `short:"r" help:"Which column number should be returned instead of whole row as string. Default=0 returns whole Row" default:"0"` + Timeout time.Duration `help:"Timeout until choose returns selected element" default:"0s" env:"GUM_TABLE_TIMEOUT"` } diff --git a/table/table.go b/table/table.go index d9a92ed..7e2b035 100644 --- a/table/table.go +++ b/table/table.go @@ -25,9 +25,7 @@ type model struct { quitting bool } -func (m model) Init() tea.Cmd { - return nil -} +func (m model) Init() tea.Cmd { return nil } func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { var cmd tea.Cmd @@ -39,9 +37,12 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.selected = m.table.SelectedRow() m.quitting = true return m, tea.Quit - case "ctrl+c", "q", "esc": + case "q", "esc": m.quitting = true return m, tea.Quit + case "ctrl+c": + m.quitting = true + return m, tea.Interrupt } } diff --git a/timeout/options.go b/timeout/options.go deleted file mode 100644 index 8dae2d5..0000000 --- a/timeout/options.go +++ /dev/null @@ -1,48 +0,0 @@ -package timeout - -import ( - "fmt" - "time" - - tea "github.com/charmbracelet/bubbletea" -) - -// Tick interval. -const tickInterval = time.Second - -// TickTimeoutMsg will be dispatched for every tick. -// Containing current timeout value -// and optional parameter to be used when handling the timeout msg. -type TickTimeoutMsg struct { - TimeoutValue time.Duration - Data interface{} -} - -// Init Start Timeout ticker using with timeout in seconds and optional data. -func Init(timeout time.Duration, data interface{}) tea.Cmd { - if timeout > 0 { - return Tick(timeout, data) - } - return nil -} - -// Start ticker. -func Tick(timeoutValue time.Duration, data interface{}) tea.Cmd { - return tea.Tick(tickInterval, func(time.Time) tea.Msg { - // every tick checks if the timeout needs to be decremented - // and send as message - if timeoutValue >= 0 { - timeoutValue -= tickInterval - return TickTimeoutMsg{ - TimeoutValue: timeoutValue, - Data: data, - } - } - return nil - }) -} - -// Str produce Timeout String to be rendered. -func Str(timeout time.Duration) string { - return fmt.Sprintf(" (%d)", max(0, int(timeout.Seconds()))) -} diff --git a/write/command.go b/write/command.go index 97a806f..736d567 100644 --- a/write/command.go +++ b/write/command.go @@ -8,10 +8,9 @@ import ( "github.com/charmbracelet/bubbles/help" "github.com/charmbracelet/bubbles/textarea" tea "github.com/charmbracelet/bubbletea" - "github.com/charmbracelet/gum/cursor" - "github.com/charmbracelet/gum/internal/exit" "github.com/charmbracelet/gum/internal/stdin" + "github.com/charmbracelet/gum/internal/timeout" ) // Run provides a shell script interface for the text area bubble. @@ -49,7 +48,7 @@ func (o Options) Run() error { a.SetHeight(o.Height) a.SetValue(o.Value) - p := tea.NewProgram(model{ + m := model{ textarea: a, header: o.Header, headerStyle: o.HeaderStyle.ToLipgloss(), @@ -57,16 +56,22 @@ func (o Options) Run() error { help: help.New(), showHelp: o.ShowHelp, keymap: defaultKeymap(), - }, tea.WithOutput(os.Stderr), tea.WithReportFocus()) + } + + ctx, cancel := timeout.Context(o.Timeout) + defer cancel() + + p := tea.NewProgram( + m, + tea.WithOutput(os.Stderr), + tea.WithReportFocus(), + tea.WithContext(ctx), + ) tm, err := p.Run() if err != nil { return fmt.Errorf("failed to run write: %w", err) } - m := tm.(model) - if m.aborted { - return exit.ErrAborted - } - + m = tm.(model) fmt.Println(m.textarea.Value()) return nil } diff --git a/write/options.go b/write/options.go index 0e33cd5..575c397 100644 --- a/write/options.go +++ b/write/options.go @@ -1,20 +1,25 @@ package write -import "github.com/charmbracelet/gum/style" +import ( + "time" + + "github.com/charmbracelet/gum/style" +) // Options are the customization options for the textarea. type Options struct { - Width int `help:"Text area width (0 for terminal width)" default:"0" env:"GUM_WRITE_WIDTH"` - Height int `help:"Text area height" default:"5" env:"GUM_WRITE_HEIGHT"` - Header string `help:"Header value" default:"" env:"GUM_WRITE_HEADER"` - Placeholder string `help:"Placeholder value" default:"Write something..." env:"GUM_WRITE_PLACEHOLDER"` - Prompt string `help:"Prompt to display" default:"┃ " env:"GUM_WRITE_PROMPT"` - ShowCursorLine bool `help:"Show cursor line" default:"false" env:"GUM_WRITE_SHOW_CURSOR_LINE"` - ShowLineNumbers bool `help:"Show line numbers" default:"false" env:"GUM_WRITE_SHOW_LINE_NUMBERS"` - Value string `help:"Initial value (can be passed via stdin)" default:"" env:"GUM_WRITE_VALUE"` - CharLimit int `help:"Maximum value length (0 for no limit)" default:"400"` - ShowHelp bool `help:"Show help key binds" negatable:"" default:"true" env:"GUM_WRITE_SHOW_HELP"` - CursorMode string `prefix:"cursor." name:"mode" help:"Cursor mode" default:"blink" enum:"blink,hide,static" env:"GUM_WRITE_CURSOR_MODE"` + Width int `help:"Text area width (0 for terminal width)" default:"0" env:"GUM_WRITE_WIDTH"` + Height int `help:"Text area height" default:"5" env:"GUM_WRITE_HEIGHT"` + Header string `help:"Header value" default:"" env:"GUM_WRITE_HEADER"` + Placeholder string `help:"Placeholder value" default:"Write something..." env:"GUM_WRITE_PLACEHOLDER"` + Prompt string `help:"Prompt to display" default:"┃ " env:"GUM_WRITE_PROMPT"` + ShowCursorLine bool `help:"Show cursor line" default:"false" env:"GUM_WRITE_SHOW_CURSOR_LINE"` + ShowLineNumbers bool `help:"Show line numbers" default:"false" env:"GUM_WRITE_SHOW_LINE_NUMBERS"` + Value string `help:"Initial value (can be passed via stdin)" default:"" env:"GUM_WRITE_VALUE"` + CharLimit int `help:"Maximum value length (0 for no limit)" default:"400"` + ShowHelp bool `help:"Show help key binds" negatable:"" default:"true" env:"GUM_WRITE_SHOW_HELP"` + CursorMode string `prefix:"cursor." name:"mode" help:"Cursor mode" default:"blink" enum:"blink,hide,static" env:"GUM_WRITE_CURSOR_MODE"` + Timeout time.Duration `help:"Timeout until choose returns selected element" default:"0s" env:"GUM_WRITE_TIMEOUT"` BaseStyle style.Styles `embed:"" prefix:"base." envprefix:"GUM_WRITE_BASE_"` CursorLineNumberStyle style.Styles `embed:"" prefix:"cursor-line-number." set:"defaultForeground=7" envprefix:"GUM_WRITE_CURSOR_LINE_NUMBER_"` diff --git a/write/write.go b/write/write.go index 4b24234..6d09253 100644 --- a/write/write.go +++ b/write/write.go @@ -23,7 +23,7 @@ import ( type keymap struct { textarea.KeyMap Submit key.Binding - Quit key.Binding + Abort key.Binding OpenInEditor key.Binding } @@ -47,7 +47,7 @@ func defaultKeymap() keymap { ) return keymap{ KeyMap: km, - Quit: key.NewBinding( + Abort: key.NewBinding( key.WithKeys("ctrl+c"), key.WithHelp("ctrl+c", "cancel"), ), @@ -64,7 +64,6 @@ func defaultKeymap() keymap { type model struct { autoWidth bool - aborted bool header string headerStyle lipgloss.Style quitting bool @@ -75,6 +74,7 @@ type model struct { } func (m model) Init() tea.Cmd { return textarea.Blink } + func (m model) View() string { if m.quitting { return "" @@ -107,18 +107,16 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, openEditor(msg.path, msg.lineno) case editorFinishedMsg: if msg.err != nil { - m.aborted = true m.quitting = true - return m, tea.Quit + return m, tea.Interrupt } m.textarea.SetValue(msg.content) case tea.KeyMsg: km := m.keymap switch { - case key.Matches(msg, km.Quit): - m.aborted = true + case key.Matches(msg, km.Abort): m.quitting = true - return m, tea.Quit + return m, tea.Interrupt case key.Matches(msg, km.Submit): m.quitting = true return m, tea.Quit From 71d7e6539c4b4de519263cf41c78b80a12c62e66 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 9 Dec 2024 14:41:29 -0300 Subject: [PATCH 069/198] feat: handle focus/blur events (#749) Signed-off-by: Carlos Alexandro Becker --- filter/command.go | 1 + filter/filter.go | 9 ++++----- input/command.go | 1 + pager/command.go | 1 + pager/pager.go | 20 ++++++++++++-------- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/filter/command.go b/filter/command.go index 1264534..e4849a5 100644 --- a/filter/command.go +++ b/filter/command.go @@ -54,6 +54,7 @@ func (o Options) Run() error { options := []tea.ProgramOption{ tea.WithOutput(os.Stderr), + tea.WithReportFocus(), tea.WithContext(ctx), } if o.Height == 0 { diff --git a/filter/filter.go b/filter/filter.go index 576ba13..33ed114 100644 --- a/filter/filter.go +++ b/filter/filter.go @@ -114,7 +114,7 @@ type model struct { strict bool } -func (m model) Init() tea.Cmd { return nil } +func (m model) Init() tea.Cmd { return textinput.Blink } func (m model) View() string { if m.quitting { @@ -229,7 +229,8 @@ func (m model) helpView() string { } func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { - var cmd tea.Cmd + var cmd, icmd tea.Cmd + m.textinput, icmd = m.textinput.Update(msg) switch msg := msg.(type) { case tea.WindowSizeMsg: if m.height == 0 || m.height > msg.Height { @@ -278,8 +279,6 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } m.ToggleSelection() default: - m.textinput, cmd = m.textinput.Update(msg) - // yOffsetFromBottom is the number of lines from the bottom of the // list to the top of the viewport. This is used to keep the viewport // at a constant position when the number of matches are reduced @@ -324,7 +323,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { // It's possible that filtering items have caused fewer matches. So, ensure // that the selected index is within the bounds of the number of matches. m.cursor = clamp(0, len(m.matches)-1, m.cursor) - return m, cmd + return m, tea.Batch(cmd, icmd) } func (m *model) CursorUp() { diff --git a/input/command.go b/input/command.go index 5553055..c625202 100644 --- a/input/command.go +++ b/input/command.go @@ -58,6 +58,7 @@ func (o Options) Run() error { p := tea.NewProgram( m, tea.WithOutput(os.Stderr), + tea.WithReportFocus(), tea.WithContext(ctx), ) tm, err := p.Run() diff --git a/pager/command.go b/pager/command.go index bf4f5be..7e84985 100644 --- a/pager/command.go +++ b/pager/command.go @@ -48,6 +48,7 @@ func (o Options) Run() error { _, err := tea.NewProgram( m, tea.WithAltScreen(), + tea.WithReportFocus(), tea.WithContext(ctx), ).Run() if err != nil { diff --git a/pager/pager.go b/pager/pager.go index 6ee2ce6..26acf06 100644 --- a/pager/pager.go +++ b/pager/pager.go @@ -7,6 +7,7 @@ import ( "fmt" "strings" + "github.com/charmbracelet/bubbles/textinput" "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" @@ -32,15 +33,17 @@ func (m model) Init() tea.Cmd { return nil } func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case tea.WindowSizeMsg: - m.ProcessText(msg) + m.processText(msg) case tea.KeyMsg: - return m.KeyHandler(msg) + return m.keyHandler(msg) } - return m, nil + var cmd tea.Cmd + m.search.input, cmd = m.search.input.Update(msg) + return m, cmd } -func (m *model) ProcessText(msg tea.WindowSizeMsg) { +func (m *model) processText(msg tea.WindowSizeMsg) { m.viewport.Height = msg.Height - lipgloss.Height(m.helpStyle.Render("?")) - 1 m.viewport.Width = msg.Width textStyle := lipgloss.NewStyle().Width(m.viewport.Width) @@ -84,7 +87,7 @@ func (m *model) ProcessText(msg tea.WindowSizeMsg) { const heightOffset = 2 -func (m model) KeyHandler(key tea.KeyMsg) (model, func() tea.Msg) { +func (m model) keyHandler(key tea.KeyMsg) (model, tea.Cmd) { var cmd tea.Cmd if m.search.active { switch key.String() { @@ -95,7 +98,7 @@ func (m model) KeyHandler(key tea.KeyMsg) (model, func() tea.Msg) { // Trigger a view update to highlight the found matches. m.search.NextMatch(&m) - m.ProcessText(tea.WindowSizeMsg{Height: m.viewport.Height + heightOffset, Width: m.viewport.Width}) + m.processText(tea.WindowSizeMsg{Height: m.viewport.Height + heightOffset, Width: m.viewport.Width}) } else { m.search.Done() } @@ -112,12 +115,13 @@ func (m model) KeyHandler(key tea.KeyMsg) (model, func() tea.Msg) { m.viewport.GotoBottom() case "/": m.search.Begin() + return m, textinput.Blink case "p", "N": m.search.PrevMatch(&m) - m.ProcessText(tea.WindowSizeMsg{Height: m.viewport.Height + heightOffset, Width: m.viewport.Width}) + m.processText(tea.WindowSizeMsg{Height: m.viewport.Height + heightOffset, Width: m.viewport.Width}) case "n": m.search.NextMatch(&m) - m.ProcessText(tea.WindowSizeMsg{Height: m.viewport.Height + heightOffset, Width: m.viewport.Width}) + m.processText(tea.WindowSizeMsg{Height: m.viewport.Height + heightOffset, Width: m.viewport.Width}) case "q", "esc": return m, tea.Quit case "ctrl+c": From fb543c3294f7d8e918bdf8b7a9da74e648cf6f45 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 9 Dec 2024 14:44:43 -0300 Subject: [PATCH 070/198] fix: strip ansi sequences from stdin (#739) Signed-off-by: Carlos Alexandro Becker --- internal/stdin/stdin.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/stdin/stdin.go b/internal/stdin/stdin.go index 1a1b0f3..26c7388 100644 --- a/internal/stdin/stdin.go +++ b/internal/stdin/stdin.go @@ -6,6 +6,8 @@ import ( "io" "os" "strings" + + "github.com/charmbracelet/x/ansi" ) // Read reads input from an stdin pipe. @@ -28,7 +30,7 @@ func Read() (string, error) { } } - return strings.TrimSuffix(b.String(), "\n"), nil + return strings.TrimSuffix(ansi.Strip(b.String()), "\n"), nil } // IsEmpty returns whether stdin is empty. From 2e2b020541de95a643d69f7b95234ab5fe8cfaae Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 9 Dec 2024 15:05:12 -0300 Subject: [PATCH 071/198] fix(pager): use help bubble (#748) --- pager/command.go | 4 +- pager/options.go | 4 +- pager/pager.go | 123 ++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 106 insertions(+), 25 deletions(-) diff --git a/pager/command.go b/pager/command.go index 7e84985..414bee7 100644 --- a/pager/command.go +++ b/pager/command.go @@ -4,6 +4,7 @@ import ( "fmt" "regexp" + "github.com/charmbracelet/bubbles/help" "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/gum/internal/stdin" @@ -32,7 +33,7 @@ func (o Options) Run() error { m := model{ viewport: vp, - helpStyle: o.HelpStyle.ToLipgloss(), + help: help.New(), content: o.Content, origContent: o.Content, showLineNumbers: o.ShowLineNumbers, @@ -40,6 +41,7 @@ func (o Options) Run() error { softWrap: o.SoftWrap, matchStyle: o.MatchStyle.ToLipgloss(), matchHighlightStyle: o.MatchHighlightStyle.ToLipgloss(), + keymap: defaultKeymap(), } ctx, cancel := timeout.Context(o.Timeout) diff --git a/pager/options.go b/pager/options.go index 15e479a..c9a0a55 100644 --- a/pager/options.go +++ b/pager/options.go @@ -10,7 +10,6 @@ import ( type Options struct { //nolint:staticcheck Style style.Styles `embed:"" help:"Style the pager" set:"defaultBorder=rounded" set:"defaultPadding=0 1" set:"defaultBorderForeground=212" envprefix:"GUM_PAGER_"` - HelpStyle style.Styles `embed:"" prefix:"help." help:"Style the help text" set:"defaultForeground=241" envprefix:"GUM_PAGER_HELP_"` Content string `arg:"" optional:"" help:"Display content to scroll"` ShowLineNumbers bool `help:"Show line numbers" default:"true"` LineNumberStyle style.Styles `embed:"" prefix:"line-number." help:"Style the line numbers" set:"defaultForeground=237" envprefix:"GUM_PAGER_LINE_NUMBER_"` @@ -18,4 +17,7 @@ type Options struct { MatchStyle style.Styles `embed:"" prefix:"match." help:"Style the matched text" set:"defaultForeground=212" set:"defaultBold=true" envprefix:"GUM_PAGER_MATCH_"` //nolint:staticcheck MatchHighlightStyle style.Styles `embed:"" prefix:"match-highlight." help:"Style the matched highlight text" set:"defaultForeground=235" set:"defaultBackground=225" set:"defaultBold=true" envprefix:"GUM_PAGER_MATCH_HIGH_"` //nolint:staticcheck Timeout time.Duration `help:"Timeout until command exits" default:"0s" env:"GUM_PAGER_TIMEOUT"` + + // Deprecated: this has no effect anymore. + HelpStyle style.Styles `embed:"" prefix:"help." help:"Style the help text" set:"defaultForeground=241" envprefix:"GUM_PAGER_HELP_" hidden:""` } diff --git a/pager/pager.go b/pager/pager.go index 26acf06..ea689bc 100644 --- a/pager/pager.go +++ b/pager/pager.go @@ -7,6 +7,8 @@ import ( "fmt" "strings" + "github.com/charmbracelet/bubbles/help" + "github.com/charmbracelet/bubbles/key" "github.com/charmbracelet/bubbles/textinput" "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" @@ -14,11 +16,83 @@ import ( "github.com/muesli/reflow/truncate" ) +type keymap struct { + Home, + End, + Search, + NextMatch, + PrevMatch, + Abort, + Quit, + ConfirmSearch, + CancelSearch key.Binding +} + +// FullHelp implements help.KeyMap. +func (k keymap) FullHelp() [][]key.Binding { + return nil +} + +// ShortHelp implements help.KeyMap. +func (k keymap) ShortHelp() []key.Binding { + return []key.Binding{ + key.NewBinding( + key.WithKeys("up", "down"), + key.WithHelp("↑/↓", "navigate"), + ), + k.Quit, + k.Search, + k.NextMatch, + k.PrevMatch, + } +} + +func defaultKeymap() keymap { + return keymap{ + Home: key.NewBinding( + key.WithKeys("g", "home"), + key.WithHelp("h", "home"), + ), + End: key.NewBinding( + key.WithKeys("G", "end"), + key.WithHelp("G", "end"), + ), + Search: key.NewBinding( + key.WithKeys("/"), + key.WithHelp("/", "search"), + ), + PrevMatch: key.NewBinding( + key.WithKeys("p", "N"), + key.WithHelp("N", "previous match"), + ), + NextMatch: key.NewBinding( + key.WithKeys("n"), + key.WithHelp("n", "next match"), + ), + Abort: key.NewBinding( + key.WithKeys("ctrl+c"), + key.WithHelp("ctrl+c", "abort"), + ), + Quit: key.NewBinding( + key.WithKeys("q", "esc"), + key.WithHelp("esc", "quit"), + ), + ConfirmSearch: key.NewBinding( + key.WithKeys("enter"), + key.WithHelp("enter", "confirm"), + ), + CancelSearch: key.NewBinding( + key.WithKeys("ctrl+c", "ctrl+d", "esc"), + key.WithHelp("ctrl+c", "cancel"), + ), + } +} + type model struct { content string origContent string viewport viewport.Model - helpStyle lipgloss.Style + help help.Model showLineNumbers bool lineNumberStyle lipgloss.Style softWrap bool @@ -26,6 +100,7 @@ type model struct { matchStyle lipgloss.Style matchHighlightStyle lipgloss.Style maxWidth int + keymap keymap } func (m model) Init() tea.Cmd { return nil } @@ -38,13 +113,20 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m.keyHandler(msg) } + m.keymap.PrevMatch.SetEnabled(m.search.query != nil) + m.keymap.NextMatch.SetEnabled(m.search.query != nil) + var cmd tea.Cmd m.search.input, cmd = m.search.input.Update(msg) return m, cmd } +func (m *model) helpView() string { + return "\n" + m.help.View(m.keymap) +} + func (m *model) processText(msg tea.WindowSizeMsg) { - m.viewport.Height = msg.Height - lipgloss.Height(m.helpStyle.Render("?")) - 1 + m.viewport.Height = msg.Height - lipgloss.Height(m.helpView()) m.viewport.Width = msg.Width textStyle := lipgloss.NewStyle().Width(m.viewport.Width) var text strings.Builder @@ -87,11 +169,12 @@ func (m *model) processText(msg tea.WindowSizeMsg) { const heightOffset = 2 -func (m model) keyHandler(key tea.KeyMsg) (model, tea.Cmd) { +func (m model) keyHandler(msg tea.KeyMsg) (model, tea.Cmd) { + km := m.keymap var cmd tea.Cmd if m.search.active { - switch key.String() { - case "enter": + switch { + case key.Matches(msg, km.ConfirmSearch): if m.search.input.Value() != "" { m.content = m.origContent m.search.Execute(&m) @@ -102,47 +185,41 @@ func (m model) keyHandler(key tea.KeyMsg) (model, tea.Cmd) { } else { m.search.Done() } - case "ctrl+d", "ctrl+c", "esc": + case key.Matches(msg, km.CancelSearch): m.search.Done() default: - m.search.input, cmd = m.search.input.Update(key) + m.search.input, cmd = m.search.input.Update(msg) } } else { - switch key.String() { - case "g", "home": + switch { + case key.Matches(msg, km.Home): m.viewport.GotoTop() - case "G", "end": + case key.Matches(msg, km.End): m.viewport.GotoBottom() - case "/": + case key.Matches(msg, km.Search): m.search.Begin() return m, textinput.Blink - case "p", "N": + case key.Matches(msg, km.PrevMatch): m.search.PrevMatch(&m) m.processText(tea.WindowSizeMsg{Height: m.viewport.Height + heightOffset, Width: m.viewport.Width}) - case "n": + case key.Matches(msg, km.NextMatch): m.search.NextMatch(&m) m.processText(tea.WindowSizeMsg{Height: m.viewport.Height + heightOffset, Width: m.viewport.Width}) - case "q", "esc": + case key.Matches(msg, km.Quit): return m, tea.Quit - case "ctrl+c": + case key.Matches(msg, km.Abort): return m, tea.Interrupt } - m.viewport, cmd = m.viewport.Update(key) + m.viewport, cmd = m.viewport.Update(msg) } return m, cmd } func (m model) View() string { - // TODO: use help bubble here - helpMsg := "\n ↑/↓: Navigate • q: Quit • /: Search " - if m.search.query != nil { - helpMsg += "• n: Next Match " - helpMsg += "• N: Prev Match " - } if m.search.active { return m.viewport.View() + "\n " + m.search.input.View() } - return m.viewport.View() + m.helpStyle.Render(helpMsg) + return m.viewport.View() + m.helpView() } From 2939e516cc776d34e9376406e7c9e910e3b440c6 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 9 Dec 2024 17:54:17 -0300 Subject: [PATCH 072/198] fix(pager): do not strip ansi sequences (#754) --- choose/command.go | 2 +- filter/command.go | 2 +- format/command.go | 2 +- input/command.go | 4 ++-- internal/stdin/stdin.go | 8 +++++++- style/command.go | 2 +- write/command.go | 2 +- 7 files changed, 14 insertions(+), 8 deletions(-) diff --git a/choose/command.go b/choose/command.go index bcd052b..fd07d84 100644 --- a/choose/command.go +++ b/choose/command.go @@ -27,7 +27,7 @@ func (o Options) Run() error { ) if len(o.Options) <= 0 { - input, _ := stdin.Read() + input, _ := stdin.ReadStrip() if input == "" { return errors.New("no options provided, see `gum choose --help`") } diff --git a/filter/command.go b/filter/command.go index e4849a5..4edbdc3 100644 --- a/filter/command.go +++ b/filter/command.go @@ -33,7 +33,7 @@ func (o Options) Run() error { v := viewport.New(o.Width, o.Height) if len(o.Options) == 0 { - if input, _ := stdin.Read(); input != "" { + if input, _ := stdin.ReadStrip(); input != "" { o.Options = strings.Split(input, "\n") } else { o.Options = files.List() diff --git a/format/command.go b/format/command.go index 82ebf0c..4cea2d9 100644 --- a/format/command.go +++ b/format/command.go @@ -24,7 +24,7 @@ func (o Options) Run() error { if len(o.Template) > 0 { input = strings.Join(o.Template, "\n") } else { - input, _ = stdin.Read() + input, _ = stdin.ReadStrip() } switch o.Type { diff --git a/input/command.go b/input/command.go index c625202..ed4ca5d 100644 --- a/input/command.go +++ b/input/command.go @@ -16,7 +16,7 @@ import ( // https://github.com/charmbracelet/bubbles/textinput func (o Options) Run() error { if o.Value == "" { - if in, _ := stdin.Read(); in != "" { + if in, _ := stdin.ReadStrip(); in != "" { o.Value = in } } @@ -24,7 +24,7 @@ func (o Options) Run() error { i := textinput.New() if o.Value != "" { i.SetValue(o.Value) - } else if in, _ := stdin.Read(); in != "" { + } else if in, _ := stdin.ReadStrip(); in != "" { i.SetValue(in) } i.Focus() diff --git a/internal/stdin/stdin.go b/internal/stdin/stdin.go index 26c7388..d946662 100644 --- a/internal/stdin/stdin.go +++ b/internal/stdin/stdin.go @@ -30,7 +30,13 @@ func Read() (string, error) { } } - return strings.TrimSuffix(ansi.Strip(b.String()), "\n"), nil + return strings.TrimSuffix(b.String(), "\n"), nil +} + +// ReadStrip reads input from an stdin pipe and strips ansi sequences. +func ReadStrip() (string, error) { + s, err := Read() + return ansi.Strip(s), err } // IsEmpty returns whether stdin is empty. diff --git a/style/command.go b/style/command.go index e698df9..80390fa 100644 --- a/style/command.go +++ b/style/command.go @@ -20,7 +20,7 @@ func (o Options) Run() error { if len(o.Text) > 0 { text = strings.Join(o.Text, "\n") } else { - text, _ = stdin.Read() + text, _ = stdin.ReadStrip() if text == "" { return errors.New("no input provided, see `gum style --help`") } diff --git a/write/command.go b/write/command.go index 736d567..e056173 100644 --- a/write/command.go +++ b/write/command.go @@ -16,7 +16,7 @@ import ( // Run provides a shell script interface for the text area bubble. // https://github.com/charmbracelet/bubbles/textarea func (o Options) Run() error { - in, _ := stdin.Read() + in, _ := stdin.ReadStrip() if in != "" && o.Value == "" { o.Value = strings.ReplaceAll(in, "\r", "") } From 01892a027f01d0976e738e042f860ca326aa0432 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 9 Dec 2024 20:53:54 -0300 Subject: [PATCH 073/198] fix(write): max height, max chars (#753) --- write/command.go | 1 + write/options.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/write/command.go b/write/command.go index e056173..ec1f171 100644 --- a/write/command.go +++ b/write/command.go @@ -28,6 +28,7 @@ func (o Options) Run() error { a.Placeholder = o.Placeholder a.ShowLineNumbers = o.ShowLineNumbers a.CharLimit = o.CharLimit + a.MaxHeight = o.MaxLines style := textarea.Style{ Base: o.BaseStyle.ToLipgloss(), diff --git a/write/options.go b/write/options.go index 575c397..96ae7a8 100644 --- a/write/options.go +++ b/write/options.go @@ -16,7 +16,8 @@ type Options struct { ShowCursorLine bool `help:"Show cursor line" default:"false" env:"GUM_WRITE_SHOW_CURSOR_LINE"` ShowLineNumbers bool `help:"Show line numbers" default:"false" env:"GUM_WRITE_SHOW_LINE_NUMBERS"` Value string `help:"Initial value (can be passed via stdin)" default:"" env:"GUM_WRITE_VALUE"` - CharLimit int `help:"Maximum value length (0 for no limit)" default:"400"` + CharLimit int `help:"Maximum value length (0 for no limit)" default:"0"` + MaxLines int `help:"Maximum number of lines (0 for no limit)" default:"0"` ShowHelp bool `help:"Show help key binds" negatable:"" default:"true" env:"GUM_WRITE_SHOW_HELP"` CursorMode string `prefix:"cursor." name:"mode" help:"Cursor mode" default:"blink" enum:"blink,hide,static" env:"GUM_WRITE_CURSOR_MODE"` Timeout time.Duration `help:"Timeout until choose returns selected element" default:"0s" env:"GUM_WRITE_TIMEOUT"` From c25be3c8c3f299a29094461f890296feacce4383 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 9 Dec 2024 22:16:58 -0300 Subject: [PATCH 074/198] feat(pager): make --soft-wrap the default closes #744 --- pager/options.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pager/options.go b/pager/options.go index c9a0a55..a44fca7 100644 --- a/pager/options.go +++ b/pager/options.go @@ -13,7 +13,7 @@ type Options struct { Content string `arg:"" optional:"" help:"Display content to scroll"` ShowLineNumbers bool `help:"Show line numbers" default:"true"` LineNumberStyle style.Styles `embed:"" prefix:"line-number." help:"Style the line numbers" set:"defaultForeground=237" envprefix:"GUM_PAGER_LINE_NUMBER_"` - SoftWrap bool `help:"Soft wrap lines" default:"false"` + SoftWrap bool `help:"Soft wrap lines" default:"true" negatable:""` MatchStyle style.Styles `embed:"" prefix:"match." help:"Style the matched text" set:"defaultForeground=212" set:"defaultBold=true" envprefix:"GUM_PAGER_MATCH_"` //nolint:staticcheck MatchHighlightStyle style.Styles `embed:"" prefix:"match-highlight." help:"Style the matched highlight text" set:"defaultForeground=235" set:"defaultBackground=225" set:"defaultBold=true" envprefix:"GUM_PAGER_MATCH_HIGH_"` //nolint:staticcheck Timeout time.Duration `help:"Timeout until command exits" default:"0s" env:"GUM_PAGER_TIMEOUT"` From afb6111258d13d265081f97c296c104046ff3392 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 10 Dec 2024 11:48:47 -0300 Subject: [PATCH 075/198] fix(spinner): set stdin and stderr fixes #266 Signed-off-by: Carlos Alexandro Becker --- spin/spin.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spin/spin.go b/spin/spin.go index 61cc7ec..bcf7c8d 100644 --- a/spin/spin.go +++ b/spin/spin.go @@ -68,7 +68,9 @@ func commandStart(command []string) tea.Cmd { executing.Stderr = io.MultiWriter(&bothbuf, &errbuf) } else { executing.Stdout = os.Stdout + executing.Stderr = os.Stderr } + executing.Stdin = os.Stdin _ = executing.Run() status := executing.ProcessState.ExitCode() if status == -1 { From b58aad189a2f35f86e75882577816dbfab09659b Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 10 Dec 2024 12:10:42 -0300 Subject: [PATCH 076/198] docs(format): add table example Signed-off-by: Carlos Alexandro Becker --- format/README.md | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/format/README.md b/format/README.md index 288f234..3bf68d0 100644 --- a/format/README.md +++ b/format/README.md @@ -7,7 +7,7 @@ Four different parse-able formats exist: 1. [Markdown](#markdown) 2. [Code](#code) 3. [Template](#template) -3. [Emoji](#emoji) +4. [Emoji](#emoji) ## Markdown @@ -43,7 +43,7 @@ Render styled input from a string template. Templating is handled by ```bash gum format --type template '{{ Bold "Tasty" }} {{ Italic "Bubble" }} {{ Color "99" "0" " Gum " }}' # Or, via stdin -echo '{{ Bold "Tasty" }} {{ Italic "Bubble" }} {{ Color "99" "0" " Gum " }}' | gum format --type template +echo '{{ Bold "Tasty" }} {{ Italic "Bubble" }} {{ Color "99" "0" " Gum " }}' | gum format --type template ``` ## Emoji @@ -55,5 +55,30 @@ Emoji](https://github.com/yuin/goldmark-emoji) ```bash gum format --type emoji 'I :heart: Bubble Gum :candy:' # You know the drill, also via stdin -echo 'I :heart: Bubble Gum :candy:' | gum format --type emoji +echo 'I :heart: Bubble Gum :candy:' | gum format --type emoji ``` + +## Tables + +Tables are rendered using [Glamour](https://github.com/charmbracelet/glamour). + +| Bubble Gum Flavor | Price | +| ----------------- | ----- | +| Strawberry | $0.99 | +| Cherry | $0.50 | +| Banana | $0.75 | +| Orange | $0.25 | +| Lemon | $0.50 | +| Lime | $0.50 | +| Grape | $0.50 | +| Watermelon | $0.50 | +| Pineapple | $0.50 | +| Blueberry | $0.50 | +| Raspberry | $0.50 | +| Cranberry | $0.50 | +| Peach | $0.50 | +| Apple | $0.50 | +| Mango | $0.50 | +| Pomegranate | $0.50 | +| Coconut | $0.50 | +| Cinnamon | $0.50 | From cc71f600f25583f63eff8a59a060d33bd8ae91d7 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 10 Dec 2024 14:45:18 -0300 Subject: [PATCH 077/198] fix(table): ignore BOM (#757) * fix(table): ignore BOM closes #520 Signed-off-by: Carlos Alexandro Becker * fix: lint issue Signed-off-by: Carlos Alexandro Becker * fix: simplify * fix: better error --------- Signed-off-by: Carlos Alexandro Becker --- go.mod | 2 +- table/bom.csv | 4 ++++ table/command.go | 16 +++++++++++----- 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 table/bom.csv diff --git a/go.mod b/go.mod index 8862262..034428c 100644 --- a/go.mod +++ b/go.mod @@ -17,6 +17,7 @@ require ( github.com/muesli/roff v0.1.0 github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a github.com/sahilm/fuzzy v0.1.1 + golang.org/x/text v0.18.0 ) require ( @@ -45,5 +46,4 @@ require ( golang.org/x/sync v0.10.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/term v0.22.0 // indirect - golang.org/x/text v0.18.0 // indirect ) diff --git a/table/bom.csv b/table/bom.csv new file mode 100644 index 0000000..e492410 --- /dev/null +++ b/table/bom.csv @@ -0,0 +1,4 @@ +"first_name","last_name","username" +"Rob","Pike",rob +Ken,Thompson,ken +"Robert","Griesemer","gri" diff --git a/table/command.go b/table/command.go index 2e6f8fa..0b2ecd1 100644 --- a/table/command.go +++ b/table/command.go @@ -12,24 +12,30 @@ import ( "github.com/charmbracelet/gum/style" "github.com/charmbracelet/lipgloss" ltable "github.com/charmbracelet/lipgloss/table" + "golang.org/x/text/encoding" + "golang.org/x/text/encoding/unicode" + "golang.org/x/text/transform" ) // Run provides a shell script interface for rendering tabular data (CSV). func (o Options) Run() error { - var reader *csv.Reader + var input *os.File if o.File != "" { - file, err := os.Open(o.File) + var err error + input, err = os.Open(o.File) if err != nil { - return fmt.Errorf("could not find file at path %s", o.File) + return fmt.Errorf("could not render file: %w", err) } - reader = csv.NewReader(file) } else { if stdin.IsEmpty() { return fmt.Errorf("no data provided") } - reader = csv.NewReader(os.Stdin) + input = os.Stdin } + defer input.Close() //nolint: errcheck + transformer := unicode.BOMOverride(encoding.Nop.NewDecoder()) + reader := csv.NewReader(transform.NewReader(input, transformer)) separatorRunes := []rune(o.Separator) if len(separatorRunes) != 1 { return fmt.Errorf("separator must be single character") From 2b090e8cb5f9dd8b62b2dfbfbcef5b6e13e70e72 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 10 Dec 2024 14:45:32 -0300 Subject: [PATCH 078/198] feat(table): add help (#756) Signed-off-by: Carlos Alexandro Becker --- table/command.go | 12 +++++++--- table/options.go | 1 + table/table.go | 60 ++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 65 insertions(+), 8 deletions(-) diff --git a/table/command.go b/table/command.go index 0b2ecd1..064ee81 100644 --- a/table/command.go +++ b/table/command.go @@ -5,6 +5,7 @@ import ( "fmt" "os" + "github.com/charmbracelet/bubbles/help" "github.com/charmbracelet/bubbles/table" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/gum/internal/stdin" @@ -123,8 +124,14 @@ func (o Options) Run() error { ctx, cancel := timeout.Context(o.Timeout) defer cancel() + m := model{ + table: table, + showHelp: o.ShowHelp, + help: help.New(), + keymap: defaultKeymap(), + } tm, err := tea.NewProgram( - model{table: table}, + m, tea.WithOutput(os.Stderr), tea.WithContext(ctx), ).Run() @@ -136,8 +143,7 @@ func (o Options) Run() error { return fmt.Errorf("failed to get selection") } - m := tm.(model) - + m = tm.(model) if o.ReturnColumn > 0 && o.ReturnColumn <= len(m.selected) { if err = writer.Write([]string{m.selected[o.ReturnColumn-1]}); err != nil { return fmt.Errorf("failed to write col %d of selected row: %w", o.ReturnColumn, err) diff --git a/table/options.go b/table/options.go index 853a8de..1b1844a 100644 --- a/table/options.go +++ b/table/options.go @@ -15,6 +15,7 @@ type Options struct { Print bool `short:"p" help:"static print" default:"false"` File string `short:"f" help:"file path" default:""` Border string `short:"b" help:"border style" default:"rounded" enum:"rounded,thick,normal,hidden,double,none"` + ShowHelp bool `help:"Show help keybinds" default:"true" negatable:"" env:"GUM_TABLE_SHOW_HELP"` BorderStyle style.Styles `embed:"" prefix:"border." envprefix:"GUM_TABLE_BORDER_"` CellStyle style.Styles `embed:"" prefix:"cell." envprefix:"GUM_TABLE_CELL_"` diff --git a/table/table.go b/table/table.go index 7e2b035..31356a3 100644 --- a/table/table.go +++ b/table/table.go @@ -15,14 +15,59 @@ package table import ( + "github.com/charmbracelet/bubbles/help" + "github.com/charmbracelet/bubbles/key" "github.com/charmbracelet/bubbles/table" tea "github.com/charmbracelet/bubbletea" ) +type keymap struct { + Navigate, + Select, + Quit, + Abort key.Binding +} + +// FullHelp implements help.KeyMap. +func (k keymap) FullHelp() [][]key.Binding { return nil } + +// ShortHelp implements help.KeyMap. +func (k keymap) ShortHelp() []key.Binding { + return []key.Binding{ + k.Navigate, + k.Select, + k.Quit, + } +} + +func defaultKeymap() keymap { + return keymap{ + Navigate: key.NewBinding( + key.WithKeys("up", "down"), + key.WithHelp("↑↓", "navigate"), + ), + Select: key.NewBinding( + key.WithKeys("enter"), + key.WithHelp("enter", "select"), + ), + Quit: key.NewBinding( + key.WithKeys("esc", "ctrl+q", "q"), + key.WithHelp("esc", "quit"), + ), + Abort: key.NewBinding( + key.WithKeys("ctrl+c"), + key.WithHelp("ctrl+c", "abort"), + ), + } +} + type model struct { table table.Model selected table.Row quitting bool + showHelp bool + help help.Model + keymap keymap } func (m model) Init() tea.Cmd { return nil } @@ -32,15 +77,16 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case tea.KeyMsg: - switch msg.String() { - case "enter": + km := m.keymap + switch { + case key.Matches(msg, km.Select): m.selected = m.table.SelectedRow() m.quitting = true return m, tea.Quit - case "q", "esc": + case key.Matches(msg, km.Quit): m.quitting = true return m, tea.Quit - case "ctrl+c": + case key.Matches(msg, km.Abort): m.quitting = true return m, tea.Interrupt } @@ -54,5 +100,9 @@ func (m model) View() string { if m.quitting { return "" } - return m.table.View() + s := m.table.View() + if m.showHelp { + s += "\n" + m.help.View(m.keymap) + } + return s } From bf06fce1c9b2f3b3bb913856387fe26241369539 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 10 Dec 2024 21:17:53 -0300 Subject: [PATCH 079/198] fix(table): set widths (#758) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I'm not sure about this, as it might be slow in big tables... This will go through all rows, calculate their widths, and set it as the column width if none was provided with `-w`. ```console $ echo -e "a,b\naaaaaaaaaaaaaaaaaaaaaaa,bbbbbbbbbbbbbbbb" | gum table a b … … $ echo -e "a,b\naaaaaaaaaaaaaaaaaaaaaaa,bbbbbbbbbbbbbbbb" | gum table a b aaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbb $ echo -e "a,b\naaaaaaaaaaaaaaaaaaaaaaa,bbbbbbbbbbbbbbbb" | gum table -w 5,5 a b aaaa… bbbb… ``` closes #285 --- table/command.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/table/command.go b/table/command.go index 064ee81..c48cfe5 100644 --- a/table/command.go +++ b/table/command.go @@ -89,6 +89,14 @@ func (o Options) Run() error { if len(row) > len(columns) { return fmt.Errorf("invalid number of columns") } + for i, col := range row { + if len(o.Widths) == 0 { + width := lipgloss.Width(col) + if width > columns[i].Width { + columns[i].Width = width + } + } + } rows = append(rows, table.Row(row)) } From a8cce1cad945972d2a066b5646776243b3080476 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 10 Dec 2024 21:18:13 -0300 Subject: [PATCH 080/198] feat(table): --lazy-quotes and --fields-per-record (#759) As per [csv.Reader]. closes #345 --- table/command.go | 2 ++ table/options.go | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/table/command.go b/table/command.go index c48cfe5..08dc725 100644 --- a/table/command.go +++ b/table/command.go @@ -37,6 +37,8 @@ func (o Options) Run() error { transformer := unicode.BOMOverride(encoding.Nop.NewDecoder()) reader := csv.NewReader(transform.NewReader(input, transformer)) + reader.LazyQuotes = o.LazyQuotes + reader.FieldsPerRecord = o.FieldsPerRecord separatorRunes := []rune(o.Separator) if len(separatorRunes) != 1 { return fmt.Errorf("separator must be single character") diff --git a/table/options.go b/table/options.go index 1b1844a..5949c92 100644 --- a/table/options.go +++ b/table/options.go @@ -8,14 +8,16 @@ import ( // Options is the customization options for the table command. type Options struct { - Separator string `short:"s" help:"Row separator" default:","` - Columns []string `short:"c" help:"Column names"` - Widths []int `short:"w" help:"Column widths"` - Height int `help:"Table height" default:"0"` - Print bool `short:"p" help:"static print" default:"false"` - File string `short:"f" help:"file path" default:""` - Border string `short:"b" help:"border style" default:"rounded" enum:"rounded,thick,normal,hidden,double,none"` - ShowHelp bool `help:"Show help keybinds" default:"true" negatable:"" env:"GUM_TABLE_SHOW_HELP"` + Separator string `short:"s" help:"Row separator" default:","` + Columns []string `short:"c" help:"Column names"` + Widths []int `short:"w" help:"Column widths"` + Height int `help:"Table height" default:"0"` + Print bool `short:"p" help:"static print" default:"false"` + File string `short:"f" help:"file path" default:""` + Border string `short:"b" help:"border style" default:"rounded" enum:"rounded,thick,normal,hidden,double,none"` + ShowHelp bool `help:"Show help keybinds" default:"true" negatable:"" env:"GUM_TABLE_SHOW_HELP"` + LazyQuotes bool `help:"If LazyQuotes is true, a quote may appear in an unquoted field and a non-doubled quote may appear in a quoted field" default:"false" env:"GUM_TABLE_LAZY_QUOTES"` + FieldsPerRecord int `help:"Sets the number of expected fields per record" default:"0" env:"GUM_TABLE_FIELDS_PER_RECORD"` BorderStyle style.Styles `embed:"" prefix:"border." envprefix:"GUM_TABLE_BORDER_"` CellStyle style.Styles `embed:"" prefix:"cell." envprefix:"GUM_TABLE_CELL_"` From 8d611cb7dfe7ebec55a7da572adf3f20c3f54a37 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 10 Dec 2024 21:26:49 -0300 Subject: [PATCH 081/198] fix(table): grow table rows based on --columns (#760) * fix(table): grow table rows based on --columns closes #411 * fix: merge --- table/command.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/table/command.go b/table/command.go index 08dc725..ae52bbf 100644 --- a/table/command.go +++ b/table/command.go @@ -87,11 +87,17 @@ func (o Options) Run() error { } rows := make([]table.Row, 0, len(data)) - for _, row := range data { - if len(row) > len(columns) { + for row := range data { + if len(data[row]) > len(columns) { return fmt.Errorf("invalid number of columns") } - for i, col := range row { + + // fixes the data in case we have more columns than rows: + for len(data[row]) < len(columns) { + data[row] = append(data[row], "") + } + + for i, col := range data[row] { if len(o.Widths) == 0 { width := lipgloss.Width(col) if width > columns[i].Width { @@ -99,7 +105,8 @@ func (o Options) Run() error { } } } - rows = append(rows, table.Row(row)) + + rows = append(rows, table.Row(data[row])) } if o.Print { From b0c9c583028bb4d3cfeea461cce3d28bcb4f2017 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 10 Dec 2024 21:27:13 -0300 Subject: [PATCH 082/198] fix(stdin): trim space instead of \n (#761) we were trimming an ending \n, but it would then break a \r\n sequence, causing misrenders. this fixes it closes #682 Signed-off-by: Carlos Alexandro Becker --- internal/stdin/stdin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/stdin/stdin.go b/internal/stdin/stdin.go index d946662..a5cebdb 100644 --- a/internal/stdin/stdin.go +++ b/internal/stdin/stdin.go @@ -30,7 +30,7 @@ func Read() (string, error) { } } - return strings.TrimSuffix(b.String(), "\n"), nil + return strings.TrimSpace(b.String()), nil } // ReadStrip reads input from an stdin pipe and strips ansi sequences. From 6f5b0d2d67b89407c8045008db5fd9ace50c9c4c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Dec 2024 04:44:38 +0000 Subject: [PATCH 083/198] chore(deps): bump github.com/charmbracelet/x/ansi from 0.5.2 to 0.6.0 (#765) Bumps [github.com/charmbracelet/x/ansi](https://github.com/charmbracelet/x) from 0.5.2 to 0.6.0. - [Release notes](https://github.com/charmbracelet/x/releases) - [Commits](https://github.com/charmbracelet/x/compare/ansi/v0.5.2...ansi/v0.6.0) --- updated-dependencies: - dependency-name: github.com/charmbracelet/x/ansi dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 034428c..d5fdf55 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/lipgloss v1.0.0 github.com/charmbracelet/log v0.4.0 - github.com/charmbracelet/x/ansi v0.5.2 + github.com/charmbracelet/x/ansi v0.6.0 github.com/charmbracelet/x/editor v0.1.0 github.com/charmbracelet/x/term v0.2.1 github.com/muesli/reflow v0.3.0 diff --git a/go.sum b/go.sum index 80fe2e8..b28af72 100644 --- a/go.sum +++ b/go.sum @@ -28,8 +28,8 @@ github.com/charmbracelet/lipgloss v1.0.0 h1:O7VkGDvqEdGi93X+DeqsQ7PKHDgtQfF8j8/O github.com/charmbracelet/lipgloss v1.0.0/go.mod h1:U5fy9Z+C38obMs+T+tJqst9VGzlOYGj4ri9reL3qUlo= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= -github.com/charmbracelet/x/ansi v0.5.2 h1:dEa1x2qdOZXD/6439s+wF7xjV+kZLu/iN00GuXXrU9E= -github.com/charmbracelet/x/ansi v0.5.2/go.mod h1:KBUFw1la39nl0dLl10l5ORDAqGXaeurTQmwyyVKse/Q= +github.com/charmbracelet/x/ansi v0.6.0 h1:qOznutrb93gx9oMiGf7caF7bqqubh6YIM0SWKyA08pA= +github.com/charmbracelet/x/ansi v0.6.0/go.mod h1:KBUFw1la39nl0dLl10l5ORDAqGXaeurTQmwyyVKse/Q= github.com/charmbracelet/x/editor v0.1.0 h1:p69/dpvlwRTs9uYiPeAWruwsHqTFzHhTvQOd/WVSX98= github.com/charmbracelet/x/editor v0.1.0/go.mod h1:oivrEbcP/AYt/Hpvk5pwDXXrQ933gQS6UzL6fxqAGSA= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q= From b45ae0e049f4efda65653112ba85169dca3e7c21 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Dec 2024 04:44:50 +0000 Subject: [PATCH 084/198] chore(deps): bump golang.org/x/text from 0.18.0 to 0.21.0 (#764) Bumps [golang.org/x/text](https://github.com/golang/text) from 0.18.0 to 0.21.0. - [Release notes](https://github.com/golang/text/releases) - [Commits](https://github.com/golang/text/compare/v0.18.0...v0.21.0) --- updated-dependencies: - dependency-name: golang.org/x/text dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d5fdf55..f1927c4 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/muesli/roff v0.1.0 github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a github.com/sahilm/fuzzy v0.1.1 - golang.org/x/text v0.18.0 + golang.org/x/text v0.21.0 ) require ( diff --git a/go.sum b/go.sum index b28af72..5e6742d 100644 --- a/go.sum +++ b/go.sum @@ -102,7 +102,7 @@ golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= -golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= -golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 6a37a14819f4b31d850c7c00171756b9d15b0262 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 11 Dec 2024 10:17:41 -0300 Subject: [PATCH 085/198] fix: update termenv to detect xterm, rio closes #391 Signed-off-by: Carlos Alexandro Becker --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f1927c4..14d781e 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/charmbracelet/x/term v0.2.1 github.com/muesli/reflow v0.3.0 github.com/muesli/roff v0.1.0 - github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a + github.com/muesli/termenv v0.15.3-0.20241211131612-0d230cb6eb15 github.com/sahilm/fuzzy v0.1.1 golang.org/x/text v0.21.0 ) diff --git a/go.sum b/go.sum index 5e6742d..a1c5b5b 100644 --- a/go.sum +++ b/go.sum @@ -73,8 +73,8 @@ github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s= github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8= github.com/muesli/roff v0.1.0 h1:YD0lalCotmYuF5HhZliKWlIx7IEhiXeSfq7hNjFqGF8= github.com/muesli/roff v0.1.0/go.mod h1:pjAHQM9hdUUwm/krAfrLGgJkXJ+YuhtsfZ42kieB2Ig= -github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a h1:2MaM6YC3mGu54x+RKAA6JiFFHlHDY1UbkxqppT7wYOg= -github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a/go.mod h1:hxSnBBYLK21Vtq/PHd0S2FYCxBXzBua8ov5s1RobyRQ= +github.com/muesli/termenv v0.15.3-0.20241211131612-0d230cb6eb15 h1:XGrI/sVwKFHXvDVSGfan37w1AFt14RLDqBqY0ThTgk0= +github.com/muesli/termenv v0.15.3-0.20241211131612-0d230cb6eb15/go.mod h1:hxSnBBYLK21Vtq/PHd0S2FYCxBXzBua8ov5s1RobyRQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= From 2e53efc0ec76a3c63c4e23c6636174daf206185d Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 11 Dec 2024 14:00:55 -0300 Subject: [PATCH 086/198] feat(style): trim line spaces (#767) Lipgloss applies aligning on the string as given to it, and ascii art usually contain left whitespaces to align things. This adds an option to trim space on all lines of the input, before giving it to lipgloss, so aligning use only non-whitespace content. --- style/ascii_a.txt | 7 +++++++ style/command.go | 7 +++++++ style/options.go | 1 + 3 files changed, 15 insertions(+) create mode 100644 style/ascii_a.txt diff --git a/style/ascii_a.txt b/style/ascii_a.txt new file mode 100644 index 0000000..ba425ec --- /dev/null +++ b/style/ascii_a.txt @@ -0,0 +1,7 @@ + # + # # + # # +# # +####### +# # +# # diff --git a/style/command.go b/style/command.go index 80390fa..be04c84 100644 --- a/style/command.go +++ b/style/command.go @@ -25,6 +25,13 @@ func (o Options) Run() error { return errors.New("no input provided, see `gum style --help`") } } + if o.Trim { + var lines []string + for _, line := range strings.Split(text, "\n") { + lines = append(lines, strings.TrimSpace(line)) + } + text = strings.Join(lines, "\n") + } fmt.Println(o.Style.ToLipgloss().Render(text)) return nil } diff --git a/style/options.go b/style/options.go index 906b551..cd2251d 100644 --- a/style/options.go +++ b/style/options.go @@ -3,6 +3,7 @@ package style // Options is the customization options for the style command. type Options struct { Text []string `arg:"" optional:"" help:"Text to which to apply the style"` + Trim bool `help:"Trim whitespaces on every input line" default:"false"` Style StylesNotHidden `embed:""` } From cf2da6406cbb2827e460cfd2cf9a2c20ed3affeb Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 11 Dec 2024 14:17:03 -0300 Subject: [PATCH 087/198] fix(spin): if not a tty, only print title, do not open tty for stdin (#763) closes #328 --- spin/command.go | 12 +++++++++--- spin/spin.go | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/spin/command.go b/spin/command.go index 5dd04eb..a792b3f 100644 --- a/spin/command.go +++ b/spin/command.go @@ -26,16 +26,22 @@ func (o Options) Run() error { align: o.Align, showOutput: o.ShowOutput && isTTY, showError: o.ShowError, + isTTY: isTTY, } ctx, cancel := timeout.Context(o.Timeout) defer cancel() - tm, err := tea.NewProgram( - m, + opts := []tea.ProgramOption{ tea.WithOutput(os.Stderr), tea.WithContext(ctx), - ).Run() + } + + if !isTTY { + opts = append(opts, tea.WithInput(nil)) + } + + tm, err := tea.NewProgram(m, opts...).Run() if err != nil { return fmt.Errorf("unable to run action: %w", err) } diff --git a/spin/spin.go b/spin/spin.go index bcf7c8d..1a38800 100644 --- a/spin/spin.go +++ b/spin/spin.go @@ -32,6 +32,7 @@ type model struct { align string command []string quitting bool + isTTY bool status int stdout string stderr string @@ -101,6 +102,10 @@ func (m model) Init() tea.Cmd { } func (m model) View() string { + if !m.isTTY { + return m.title + } + if m.quitting && m.showOutput { return strings.TrimPrefix(errbuf.String()+"\n"+outbuf.String(), "\n") } From 05614c8196b9289cf42c15feb0759a344ed4825e Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 11 Dec 2024 14:22:26 -0300 Subject: [PATCH 088/198] feat(table): set --print if stdout is not a terminal (#762) Signed-off-by: Carlos Alexandro Becker --- table/command.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/table/command.go b/table/command.go index ae52bbf..3cdb81c 100644 --- a/table/command.go +++ b/table/command.go @@ -13,6 +13,7 @@ import ( "github.com/charmbracelet/gum/style" "github.com/charmbracelet/lipgloss" ltable "github.com/charmbracelet/lipgloss/table" + "github.com/charmbracelet/x/term" "golang.org/x/text/encoding" "golang.org/x/text/encoding/unicode" "golang.org/x/text/transform" @@ -109,7 +110,7 @@ func (o Options) Run() error { rows = append(rows, table.Row(data[row])) } - if o.Print { + if o.Print || !term.IsTerminal(os.Stdout.Fd()) { table := ltable.New(). Headers(columnNames...). Rows(data...). From 774667a943d8665b631aa039cca4d94162314c66 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 11 Dec 2024 23:23:33 -0300 Subject: [PATCH 089/198] feat(choose,confirm,file,filter,input,table,write): esc exit 1, ctrl+c exit 130, help arrow order (#771) Signed-off-by: Carlos Alexandro Becker --- choose/choose.go | 19 ++++++++++++------- choose/command.go | 3 +++ confirm/confirm.go | 2 +- file/file.go | 8 ++++---- filter/command.go | 3 +++ filter/filter.go | 16 ++++++++++++---- gum.go | 2 +- input/command.go | 4 ++++ input/input.go | 7 ++++++- pager/pager.go | 2 +- table/table.go | 2 +- write/command.go | 4 ++++ write/write.go | 10 ++++++++++ 13 files changed, 62 insertions(+), 20 deletions(-) diff --git a/choose/choose.go b/choose/choose.go index 2c2e117..ff6cf5e 100644 --- a/choose/choose.go +++ b/choose/choose.go @@ -24,23 +24,18 @@ func defaultKeymap() keymap { return keymap{ Down: key.NewBinding( key.WithKeys("down", "j", "ctrl+j", "ctrl+n"), - key.WithHelp("↓", "down"), ), Up: key.NewBinding( key.WithKeys("up", "k", "ctrl+k", "ctrl+p"), - key.WithHelp("↑", "up"), ), Right: key.NewBinding( key.WithKeys("right", "l", "ctrl+f"), - key.WithHelp("→", "right"), ), Left: key.NewBinding( key.WithKeys("left", "h", "ctrl+b"), - key.WithHelp("←", "left"), ), Home: key.NewBinding( key.WithKeys("g", "home"), - key.WithHelp("g", "home"), ), End: key.NewBinding( key.WithKeys("G", "end"), @@ -57,9 +52,13 @@ func defaultKeymap() keymap { key.WithDisabled(), ), Abort: key.NewBinding( - key.WithKeys("ctrl+c", "esc"), + key.WithKeys("ctrl+c"), key.WithHelp("ctrl+c", "abort"), ), + Quit: key.NewBinding( + key.WithKeys("esc"), + key.WithHelp("esc", "quit"), + ), Submit: key.NewBinding( key.WithKeys("enter", "ctrl+q"), key.WithHelp("enter", "submit"), @@ -77,6 +76,7 @@ type keymap struct { ToggleAll, Toggle, Abort, + Quit, Submit key.Binding } @@ -89,7 +89,7 @@ func (k keymap) ShortHelp() []key.Binding { k.Toggle, key.NewBinding( key.WithKeys("up", "down", "right", "left"), - key.WithHelp("↑↓←→", "navigate"), + key.WithHelp("←↓↑→", "navigate"), ), k.Submit, k.ToggleAll, @@ -105,6 +105,7 @@ type model struct { header string items []item quitting bool + submitted bool index int limit int numSelected int @@ -177,6 +178,9 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } else { m = m.deselectAll() } + case key.Matches(msg, km.Quit): + m.quitting = true + return m, tea.Quit case key.Matches(msg, km.Abort): m.quitting = true return m, tea.Interrupt @@ -199,6 +203,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if m.limit <= 1 && m.numSelected < 1 { m.items[m.index].selected = true } + m.submitted = true return m, tea.Quit } } diff --git a/choose/command.go b/choose/command.go index fd07d84..39c2bcc 100644 --- a/choose/command.go +++ b/choose/command.go @@ -136,6 +136,9 @@ func (o Options) Run() error { return fmt.Errorf("unable to pick selection: %w", err) } m = tm.(model) + if !m.submitted { + return errors.New("nothing selected") + } if o.Ordered && o.Limit > 1 { sort.Slice(m.items, func(i, j int) bool { return m.items[i].order < m.items[j].order diff --git a/confirm/confirm.go b/confirm/confirm.go index 95d911c..21349fa 100644 --- a/confirm/confirm.go +++ b/confirm/confirm.go @@ -47,7 +47,7 @@ func defaultKeymap(affirmative, negative string) keymap { "ctrl+p", "tab", ), - key.WithHelp("←/→", "toggle"), + key.WithHelp("←→", "toggle"), ), Submit: key.NewBinding( key.WithKeys("enter"), diff --git a/file/file.go b/file/file.go index b3ddede..1e67b68 100644 --- a/file/file.go +++ b/file/file.go @@ -34,8 +34,6 @@ var keyAbort = key.NewBinding( func defaultKeymap() keymap { km := filepicker.DefaultKeyMap() - km.Down.SetHelp("↓", "down") - km.Up.SetHelp("↑", "up") return keymap(km) } @@ -45,8 +43,10 @@ func (k keymap) FullHelp() [][]key.Binding { return nil } // ShortHelp implements help.KeyMap. func (k keymap) ShortHelp() []key.Binding { return []key.Binding{ - k.Up, - k.Down, + key.NewBinding( + key.WithKeys("up", "down"), + key.WithHelp("↓↑", "navigate"), + ), keyQuit, k.Select, } diff --git a/filter/command.go b/filter/command.go index 4edbdc3..1c5a6ca 100644 --- a/filter/command.go +++ b/filter/command.go @@ -119,6 +119,9 @@ func (o Options) Run() error { } m := tm.(model) + if !m.submitted { + return errors.New("nothing selected") + } isTTY := term.IsTerminal(os.Stdout.Fd()) // allSelections contains values only if limit is greater diff --git a/filter/filter.go b/filter/filter.go index 33ed114..77c609b 100644 --- a/filter/filter.go +++ b/filter/filter.go @@ -26,11 +26,9 @@ func defaultKeymap() keymap { return keymap{ Down: key.NewBinding( key.WithKeys("down", "ctrl+j", "ctrl+n"), - key.WithHelp("↓", "down"), ), Up: key.NewBinding( key.WithKeys("up", "ctrl+k", "ctrl+p"), - key.WithHelp("↑", "up"), ), ToggleAndNext: key.NewBinding( key.WithKeys("tab"), @@ -47,8 +45,12 @@ func defaultKeymap() keymap { key.WithHelp("ctrl+@", "toggle"), key.WithDisabled(), ), + Quit: key.NewBinding( + key.WithKeys("esc"), + key.WithHelp("esc", "quit"), + ), Abort: key.NewBinding( - key.WithKeys("ctrl+c", "esc"), + key.WithKeys("ctrl+c"), key.WithHelp("ctrl+c", "abort"), ), Submit: key.NewBinding( @@ -65,6 +67,7 @@ type keymap struct { ToggleAndPrevious, Toggle, Abort, + Quit, Submit key.Binding } @@ -77,7 +80,7 @@ func (k keymap) ShortHelp() []key.Binding { k.ToggleAndNext, key.NewBinding( key.WithKeys("up", "down"), - key.WithHelp("↑↓", "navigate"), + key.WithHelp("↓↑", "navigate"), ), k.Submit, } @@ -112,6 +115,7 @@ type model struct { keymap keymap help help.Model strict bool + submitted bool } func (m model) Init() tea.Cmd { return textinput.Blink } @@ -251,11 +255,15 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case tea.KeyMsg: km := m.keymap switch { + case key.Matches(msg, km.Quit): + m.quitting = true + return m, tea.Quit case key.Matches(msg, km.Abort): m.quitting = true return m, tea.Interrupt case key.Matches(msg, km.Submit): m.quitting = true + m.submitted = true return m, tea.Quit case key.Matches(msg, km.Down): m.CursorDown() diff --git a/gum.go b/gum.go index 2808c76..7a59f20 100644 --- a/gum.go +++ b/gum.go @@ -133,7 +133,7 @@ type Gum struct { // │ 7 │ │ // │ 8 │ │ // ╰────────────────────────────────────────────────╯ - // ↑/↓: Navigate • q: Quit + // ↓↑: navigate • q: quit // Pager pager.Options `cmd:"" help:"Scroll through a file"` diff --git a/input/command.go b/input/command.go index ed4ca5d..05dc1e3 100644 --- a/input/command.go +++ b/input/command.go @@ -1,6 +1,7 @@ package input import ( + "errors" "fmt" "os" @@ -67,6 +68,9 @@ func (o Options) Run() error { } m = tm.(model) + if !m.submitted { + return errors.New("not submitted") + } fmt.Println(m.textinput.Value()) return nil } diff --git a/input/input.go b/input/input.go index 89b88ab..505b052 100644 --- a/input/input.go +++ b/input/input.go @@ -41,6 +41,7 @@ type model struct { headerStyle lipgloss.Style textinput textinput.Model quitting bool + submitted bool showHelp bool help help.Model keymap keymap @@ -79,9 +80,13 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case "ctrl+c": m.quitting = true return m, tea.Interrupt - case "esc", "enter": + case "esc": m.quitting = true return m, tea.Quit + case "enter": + m.quitting = true + m.submitted = true + return m, tea.Quit } } diff --git a/pager/pager.go b/pager/pager.go index ea689bc..2ee9b1e 100644 --- a/pager/pager.go +++ b/pager/pager.go @@ -38,7 +38,7 @@ func (k keymap) ShortHelp() []key.Binding { return []key.Binding{ key.NewBinding( key.WithKeys("up", "down"), - key.WithHelp("↑/↓", "navigate"), + key.WithHelp("↓↑", "navigate"), ), k.Quit, k.Search, diff --git a/table/table.go b/table/table.go index 31356a3..cbbb213 100644 --- a/table/table.go +++ b/table/table.go @@ -44,7 +44,7 @@ func defaultKeymap() keymap { return keymap{ Navigate: key.NewBinding( key.WithKeys("up", "down"), - key.WithHelp("↑↓", "navigate"), + key.WithHelp("↓↑", "navigate"), ), Select: key.NewBinding( key.WithKeys("enter"), diff --git a/write/command.go b/write/command.go index ec1f171..34669cb 100644 --- a/write/command.go +++ b/write/command.go @@ -1,6 +1,7 @@ package write import ( + "errors" "fmt" "os" "strings" @@ -73,6 +74,9 @@ func (o Options) Run() error { return fmt.Errorf("failed to run write: %w", err) } m = tm.(model) + if !m.submitted { + return errors.New("not submitted") + } fmt.Println(m.textarea.Value()) return nil } diff --git a/write/write.go b/write/write.go index 6d09253..978bf0d 100644 --- a/write/write.go +++ b/write/write.go @@ -23,6 +23,7 @@ import ( type keymap struct { textarea.KeyMap Submit key.Binding + Quit key.Binding Abort key.Binding OpenInEditor key.Binding } @@ -47,6 +48,10 @@ func defaultKeymap() keymap { ) return keymap{ KeyMap: km, + Quit: key.NewBinding( + key.WithKeys("esc"), + key.WithHelp("esc", "quit"), + ), Abort: key.NewBinding( key.WithKeys("ctrl+c"), key.WithHelp("ctrl+c", "cancel"), @@ -67,6 +72,7 @@ type model struct { header string headerStyle lipgloss.Style quitting bool + submitted bool textarea textarea.Model showHelp bool help help.Model @@ -117,8 +123,12 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case key.Matches(msg, km.Abort): m.quitting = true return m, tea.Interrupt + case key.Matches(msg, km.Quit): + m.quitting = true + return m, tea.Quit case key.Matches(msg, km.Submit): m.quitting = true + m.submitted = true return m, tea.Quit case key.Matches(msg, km.OpenInEditor): //nolint: gosec From 55120aead67ca48273af5e7449523bc344b5cf65 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 11 Dec 2024 23:23:58 -0300 Subject: [PATCH 090/198] feat(choose): --selected="*" to select all (#769) close #390 Signed-off-by: Carlos Alexandro Becker --- choose/command.go | 4 +++- choose/options.go | 37 +++++++++++++++++++------------------ 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/choose/command.go b/choose/command.go index 39c2bcc..ea9faf7 100644 --- a/choose/command.go +++ b/choose/command.go @@ -55,6 +55,8 @@ func (o Options) Run() error { slices.SortFunc(o.Options, strings.Compare) } + isSelectAll := len(o.Selected) == 1 && o.Selected[0] == "*" + // Keep track of the selected items. currentSelected := 0 // Check if selected items should be used. @@ -65,7 +67,7 @@ func (o Options) Run() error { for i, option := range o.Options { var order int // Check if the option should be selected. - isSelected := hasSelectedItems && currentSelected < o.Limit && slices.Contains(o.Selected, option) + isSelected := hasSelectedItems && currentSelected < o.Limit && (isSelectAll || slices.Contains(o.Selected, option)) // If the option is selected then increment the current selected count. if isSelected { if o.Limit == 1 { diff --git a/choose/options.go b/choose/options.go index ff11c92..ec44134 100644 --- a/choose/options.go +++ b/choose/options.go @@ -8,22 +8,23 @@ import ( // Options is the customization options for the choose command. type Options struct { - Options []string `arg:"" optional:"" help:"Options to choose from."` - Limit int `help:"Maximum number of options to pick" default:"1" group:"Selection"` - NoLimit bool `help:"Pick unlimited number of options (ignores limit)" group:"Selection"` - Ordered bool `help:"Maintain the order of the selected options" env:"GUM_CHOOSE_ORDERED"` - Height int `help:"Height of the list" default:"10" env:"GUM_CHOOSE_HEIGHT"` - Cursor string `help:"Prefix to show on item that corresponds to the cursor position" default:"> " env:"GUM_CHOOSE_CURSOR"` - ShowHelp bool `help:"Show help keybinds" default:"true" negatable:"" env:"GUM_CHOOSE_SHOW_HELP"` - Header string `help:"Header value" default:"Choose:" env:"GUM_CHOOSE_HEADER"` - CursorPrefix string `help:"Prefix to show on the cursor item (hidden if limit is 1)" default:"• " env:"GUM_CHOOSE_CURSOR_PREFIX"` - SelectedPrefix string `help:"Prefix to show on selected items (hidden if limit is 1)" default:"✓ " env:"GUM_CHOOSE_SELECTED_PREFIX"` - UnselectedPrefix string `help:"Prefix to show on unselected items (hidden if limit is 1)" default:"• " env:"GUM_CHOOSE_UNSELECTED_PREFIX"` - Selected []string `help:"Options that should start as selected" default:"" env:"GUM_CHOOSE_SELECTED"` - SelectIfOne bool `help:"Select the given option if there is only one" group:"Selection"` - CursorStyle style.Styles `embed:"" prefix:"cursor." set:"defaultForeground=212" envprefix:"GUM_CHOOSE_CURSOR_"` - HeaderStyle style.Styles `embed:"" prefix:"header." set:"defaultForeground=99" envprefix:"GUM_CHOOSE_HEADER_"` - ItemStyle style.Styles `embed:"" prefix:"item." hidden:"" envprefix:"GUM_CHOOSE_ITEM_"` - SelectedItemStyle style.Styles `embed:"" prefix:"selected." set:"defaultForeground=212" envprefix:"GUM_CHOOSE_SELECTED_"` - Timeout time.Duration `help:"Timeout until choose returns selected element" default:"0s" env:"GUM_CCHOOSE_TIMEOUT"` // including timeout command options [Timeout,...] + Options []string `arg:"" optional:"" help:"Options to choose from."` + Limit int `help:"Maximum number of options to pick" default:"1" group:"Selection"` + NoLimit bool `help:"Pick unlimited number of options (ignores limit)" group:"Selection"` + Ordered bool `help:"Maintain the order of the selected options" env:"GUM_CHOOSE_ORDERED"` + Height int `help:"Height of the list" default:"10" env:"GUM_CHOOSE_HEIGHT"` + Cursor string `help:"Prefix to show on item that corresponds to the cursor position" default:"> " env:"GUM_CHOOSE_CURSOR"` + ShowHelp bool `help:"Show help keybinds" default:"true" negatable:"" env:"GUM_CHOOSE_SHOW_HELP"` + Timeout time.Duration `help:"Timeout until choose returns selected element" default:"0s" env:"GUM_CCHOOSE_TIMEOUT"` // including timeout command options [Timeout,...] + Header string `help:"Header value" default:"Choose:" env:"GUM_CHOOSE_HEADER"` + CursorPrefix string `help:"Prefix to show on the cursor item (hidden if limit is 1)" default:"• " env:"GUM_CHOOSE_CURSOR_PREFIX"` + SelectedPrefix string `help:"Prefix to show on selected items (hidden if limit is 1)" default:"✓ " env:"GUM_CHOOSE_SELECTED_PREFIX"` + UnselectedPrefix string `help:"Prefix to show on unselected items (hidden if limit is 1)" default:"• " env:"GUM_CHOOSE_UNSELECTED_PREFIX"` + Selected []string `help:"Options that should start as selected (selects all if given '*')" default:"" env:"GUM_CHOOSE_SELECTED"` + SelectIfOne bool `help:"Select the given option if there is only one" group:"Selection"` + + CursorStyle style.Styles `embed:"" prefix:"cursor." set:"defaultForeground=212" envprefix:"GUM_CHOOSE_CURSOR_"` + HeaderStyle style.Styles `embed:"" prefix:"header." set:"defaultForeground=99" envprefix:"GUM_CHOOSE_HEADER_"` + ItemStyle style.Styles `embed:"" prefix:"item." hidden:"" envprefix:"GUM_CHOOSE_ITEM_"` + SelectedItemStyle style.Styles `embed:"" prefix:"selected." set:"defaultForeground=212" envprefix:"GUM_CHOOSE_SELECTED_"` } From f921ebd07f8ec20e1742701f89e08a6cdf623d2c Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 11 Dec 2024 23:24:25 -0300 Subject: [PATCH 091/198] feat(file): add --header (#768) * feat(file): add --header closes #497 * fix: show help --- file/command.go | 10 ++++++---- file/file.go | 13 ++++++++++--- file/options.go | 26 +++++++++++++------------- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/file/command.go b/file/command.go index 28ef0aa..89472dd 100644 --- a/file/command.go +++ b/file/command.go @@ -47,10 +47,12 @@ func (o Options) Run() error { fp.Styles.Selected = o.SelectedStyle.ToLipgloss() fp.Styles.FileSize = o.FileSizeStyle.ToLipgloss() m := model{ - filepicker: fp, - showHelp: o.ShowHelp, - help: help.New(), - keymap: defaultKeymap(), + filepicker: fp, + showHelp: o.ShowHelp, + help: help.New(), + keymap: defaultKeymap(), + headerStyle: o.HeaderStyle.ToLipgloss(), + header: o.Header, } ctx, cancel := timeout.Context(o.Timeout) diff --git a/file/file.go b/file/file.go index 1e67b68..17ad144 100644 --- a/file/file.go +++ b/file/file.go @@ -53,6 +53,8 @@ func (k keymap) ShortHelp() []key.Binding { } type model struct { + header string + headerStyle lipgloss.Style filepicker filepicker.Model selectedPath string quitting bool @@ -93,10 +95,15 @@ func (m model) View() string { if m.quitting { return "" } - if !m.showHelp { - return m.filepicker.View() + var parts []string + if m.header != "" { + parts = append(parts, m.headerStyle.Render(m.header)) } - return m.filepicker.View() + m.helpView() + parts = append(parts, m.filepicker.View()) + if m.showHelp { + parts = append(parts, m.helpView()) + } + return lipgloss.JoinVertical(lipgloss.Left, parts...) } func (m model) helpView() string { diff --git a/file/options.go b/file/options.go index 2aa5e5b..72bfb8f 100644 --- a/file/options.go +++ b/file/options.go @@ -11,23 +11,23 @@ type Options struct { // Path is the path to the folder / directory to begin traversing. Path string `arg:"" optional:"" name:"path" help:"The path to the folder to begin traversing" env:"GUM_FILE_PATH"` // Cursor is the character to display in front of the current selected items. - Cursor string `short:"c" help:"The cursor character" default:">" env:"GUM_FILE_CURSOR"` - All bool `short:"a" help:"Show hidden and 'dot' files" default:"false" env:"GUM_FILE_ALL"` - Permissions bool `short:"p" help:"Show file permissions" default:"true" negatable:"" env:"GUM_FILE_PERMISSION"` - Size bool `short:"s" help:"Show file size" default:"true" negatable:"" env:"GUM_FILE_SIZE"` - File bool `help:"Allow files selection" default:"true" env:"GUM_FILE_FILE"` - Directory bool `help:"Allow directories selection" default:"false" env:"GUM_FILE_DIRECTORY"` - ShowHelp bool `help:"Show help key binds" negatable:"" default:"true" env:"GUM_FILE_SHOW_HELP"` + Cursor string `short:"c" help:"The cursor character" default:">" env:"GUM_FILE_CURSOR"` + All bool `short:"a" help:"Show hidden and 'dot' files" default:"false" env:"GUM_FILE_ALL"` + Permissions bool `short:"p" help:"Show file permissions" default:"true" negatable:"" env:"GUM_FILE_PERMISSION"` + Size bool `short:"s" help:"Show file size" default:"true" negatable:"" env:"GUM_FILE_SIZE"` + File bool `help:"Allow files selection" default:"true" env:"GUM_FILE_FILE"` + Directory bool `help:"Allow directories selection" default:"false" env:"GUM_FILE_DIRECTORY"` + ShowHelp bool `help:"Show help key binds" negatable:"" default:"true" env:"GUM_FILE_SHOW_HELP"` + Timeout time.Duration `help:"Timeout until command aborts without a selection" default:"0s" env:"GUM_FILE_TIMEOUT"` + Header string `help:"Header value" default:"" env:"GUM_FILE_HEADER"` + Height int `help:"Maximum number of files to display" default:"10" env:"GUM_FILE_HEIGHT"` - Height int `help:"Maximum number of files to display" default:"10" env:"GUM_FILE_HEIGHT"` CursorStyle style.Styles `embed:"" prefix:"cursor." help:"The cursor style" set:"defaultForeground=212" envprefix:"GUM_FILE_CURSOR_"` SymlinkStyle style.Styles `embed:"" prefix:"symlink." help:"The style to use for symlinks" set:"defaultForeground=36" envprefix:"GUM_FILE_SYMLINK_"` DirectoryStyle style.Styles `embed:"" prefix:"directory." help:"The style to use for directories" set:"defaultForeground=99" envprefix:"GUM_FILE_DIRECTORY_"` FileStyle style.Styles `embed:"" prefix:"file." help:"The style to use for files" envprefix:"GUM_FILE_FILE_"` PermissionsStyle style.Styles `embed:"" prefix:"permissions." help:"The style to use for permissions" set:"defaultForeground=244" envprefix:"GUM_FILE_PERMISSIONS_"` - //nolint:staticcheck - SelectedStyle style.Styles `embed:"" prefix:"selected." help:"The style to use for the selected item" set:"defaultBold=true" set:"defaultForeground=212" envprefix:"GUM_FILE_SELECTED_"` - //nolint:staticcheck - FileSizeStyle style.Styles `embed:"" prefix:"file-size." help:"The style to use for file sizes" set:"defaultWidth=8" set:"defaultAlign=right" set:"defaultForeground=240" envprefix:"GUM_FILE_FILE_SIZE_"` - Timeout time.Duration `help:"Timeout until command aborts without a selection" default:"0s" env:"GUM_FILE_TIMEOUT"` + SelectedStyle style.Styles `embed:"" prefix:"selected." help:"The style to use for the selected item" set:"defaultBold=true" set:"defaultForeground=212" envprefix:"GUM_FILE_SELECTED_"` //nolint:staticcheck + FileSizeStyle style.Styles `embed:"" prefix:"file-size." help:"The style to use for file sizes" set:"defaultWidth=8" set:"defaultAlign=right" set:"defaultForeground=240" envprefix:"GUM_FILE_FILE_SIZE_"` //nolint:staticcheck + HeaderStyle style.Styles `embed:"" prefix:"header." set:"defaultForeground=99" envprefix:"GUM_FILE_HEADER_"` } From 74c1079c9db696ec96d6d20037dbb9a3c3e5e2bf Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Thu, 12 Dec 2024 10:12:28 -0300 Subject: [PATCH 092/198] feat(filter): ctrl+a to toggle select all (#770) closes #388 --- filter/command.go | 1 + filter/filter.go | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/filter/command.go b/filter/command.go index 1c5a6ca..dfc8274 100644 --- a/filter/command.go +++ b/filter/command.go @@ -83,6 +83,7 @@ func (o Options) Run() error { km.Toggle.SetEnabled(true) km.ToggleAndPrevious.SetEnabled(true) km.ToggleAndNext.SetEnabled(true) + km.ToggleAll.SetEnabled(true) } p := tea.NewProgram(model{ diff --git a/filter/filter.go b/filter/filter.go index 77c609b..23c0006 100644 --- a/filter/filter.go +++ b/filter/filter.go @@ -45,6 +45,11 @@ func defaultKeymap() keymap { key.WithHelp("ctrl+@", "toggle"), key.WithDisabled(), ), + ToggleAll: key.NewBinding( + key.WithKeys("ctrl+a"), + key.WithHelp("ctrl+a", "select all"), + key.WithDisabled(), + ), Quit: key.NewBinding( key.WithKeys("esc"), key.WithHelp("esc", "quit"), @@ -65,6 +70,7 @@ type keymap struct { Up, ToggleAndNext, ToggleAndPrevious, + ToggleAll, Toggle, Abort, Quit, @@ -77,11 +83,12 @@ func (k keymap) FullHelp() [][]key.Binding { return nil } // ShortHelp implements help.KeyMap. func (k keymap) ShortHelp() []key.Binding { return []key.Binding{ - k.ToggleAndNext, key.NewBinding( key.WithKeys("up", "down"), key.WithHelp("↓↑", "navigate"), ), + k.ToggleAndNext, + k.ToggleAll, k.Submit, } } @@ -286,6 +293,15 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { break // no op } m.ToggleSelection() + case key.Matches(msg, km.ToggleAll): + if m.limit <= 1 { + break + } + if m.numSelected < len(m.matches) && m.numSelected < m.limit { + m = m.selectAll() + } else { + m = m.deselectAll() + } default: // yOffsetFromBottom is the number of lines from the bottom of the // list to the top of the viewport. This is used to keep the viewport @@ -390,6 +406,26 @@ func (m *model) ToggleSelection() { } } +func (m model) selectAll() model { + for i := range m.matches { + if m.numSelected >= m.limit { + break // do not exceed given limit + } + if _, ok := m.selected[m.matches[i].Str]; ok { + continue + } + m.selected[m.matches[i].Str] = struct{}{} + m.numSelected++ + } + return m +} + +func (m model) deselectAll() model { + m.selected = make(map[string]struct{}) + m.numSelected = 0 + return m +} + func matchAll(options []string) []fuzzy.Match { matches := make([]fuzzy.Match, len(options)) for i, option := range options { From d1bfd569ca98226745bf6f88beb4cf9eda358034 Mon Sep 17 00:00:00 2001 From: vahnrr Date: Thu, 12 Dec 2024 20:02:19 +0100 Subject: [PATCH 093/198] feat(confirm): add `--show-output` (#427) * feat(confirm): add `--show-output` * feat(confirm): add `--show-output` model --------- Co-authored-by: vahnrr --- confirm/command.go | 9 +++++++++ confirm/confirm.go | 1 + confirm/options.go | 1 + 3 files changed, 11 insertions(+) diff --git a/confirm/command.go b/confirm/command.go index 2e83f6d..ac151ad 100644 --- a/confirm/command.go +++ b/confirm/command.go @@ -19,6 +19,7 @@ func (o Options) Run() error { m := model{ affirmative: o.Affirmative, negative: o.Negative, + showOutput: o.ShowOutput, confirmation: o.Default, defaultSelection: o.Default, keys: defaultKeymap(o.Affirmative, o.Negative), @@ -38,6 +39,14 @@ func (o Options) Run() error { return fmt.Errorf("unable to confirm: %w", err) } + if o.ShowOutput { + confirmationText := m.negative + if m.confirmation { + confirmationText = m.affirmative + } + fmt.Println(m.prompt, confirmationText) + } + m = tm.(model) if m.confirmation { return nil diff --git a/confirm/confirm.go b/confirm/confirm.go index 21349fa..c32ade9 100644 --- a/confirm/confirm.go +++ b/confirm/confirm.go @@ -82,6 +82,7 @@ type model struct { help help.Model keys keymap + showOutput bool confirmation bool defaultSelection bool diff --git a/confirm/options.go b/confirm/options.go index 7337711..b38d7e0 100644 --- a/confirm/options.go +++ b/confirm/options.go @@ -9,6 +9,7 @@ import ( // Options is the customization options for the confirm command. type Options struct { Default bool `help:"Default confirmation action" default:"true"` + ShowOutput bool `help:"Print prompt and chosen action to output" default:"false"` Affirmative string `help:"The title of the affirmative action" default:"Yes"` Negative string `help:"The title of the negative action" default:"No"` Prompt string `arg:"" help:"Prompt to display." default:"Are you sure?"` From 32786f7764ce58acb5da8319912459043e2bbb73 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 13 Dec 2024 14:34:10 -0300 Subject: [PATCH 094/198] feat(spin): --show-stdout --show-stderr (#774) closes #362 --- spin/command.go | 3 ++- spin/options.go | 4 +++- spin/spin.go | 20 +++++++++++++------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/spin/command.go b/spin/command.go index a792b3f..20b31fa 100644 --- a/spin/command.go +++ b/spin/command.go @@ -24,7 +24,8 @@ func (o Options) Run() error { title: o.TitleStyle.ToLipgloss().Render(o.Title), command: o.Command, align: o.Align, - showOutput: o.ShowOutput && isTTY, + showStdout: (o.ShowOutput || o.ShowStdout) && isTTY, + showStderr: (o.ShowOutput || o.ShowStderr) && isTTY, showError: o.ShowError, isTTY: isTTY, } diff --git a/spin/options.go b/spin/options.go index e0b3208..5243eab 100644 --- a/spin/options.go +++ b/spin/options.go @@ -10,8 +10,10 @@ import ( type Options struct { Command []string `arg:"" help:"Command to run"` - ShowOutput bool `help:"Show or pipe output of command during execution" default:"false" env:"GUM_SPIN_SHOW_OUTPUT"` + ShowOutput bool `help:"Show or pipe output of command during execution (shows both STDOUT and STDERR)" default:"false" env:"GUM_SPIN_SHOW_OUTPUT"` ShowError bool `help:"Show output of command only if the command fails" default:"false" env:"GUM_SPIN_SHOW_ERROR"` + ShowStdout bool `help:"Show STDOUT output" default:"false" env:"GUM_SPIN_SHOW_STDOUT"` + ShowStderr bool `help:"Show STDERR errput" default:"false" env:"GUM_SPIN_SHOW_STDERR"` Spinner string `help:"Spinner type" short:"s" type:"spinner" enum:"line,dot,minidot,jump,pulse,points,globe,moon,monkey,meter,hamburger" default:"dot" env:"GUM_SPIN_SPINNER"` SpinnerStyle style.Styles `embed:"" prefix:"spinner." set:"defaultForeground=212" envprefix:"GUM_SPIN_SPINNER_"` Title string `help:"Text to display to user while spinning" default:"Loading..." env:"GUM_SPIN_TITLE"` diff --git a/spin/spin.go b/spin/spin.go index 1a38800..cb9a1aa 100644 --- a/spin/spin.go +++ b/spin/spin.go @@ -37,7 +37,8 @@ type model struct { stdout string stderr string output string - showOutput bool + showStdout bool + showStderr bool showError bool } @@ -106,8 +107,16 @@ func (m model) View() string { return m.title } - if m.quitting && m.showOutput { - return strings.TrimPrefix(errbuf.String()+"\n"+outbuf.String(), "\n") + var out string + if m.showStderr { + out += errbuf.String() + } + if m.showStdout { + out += outbuf.String() + } + + if m.quitting && out != "" { + return out } var header string @@ -116,10 +125,7 @@ func (m model) View() string { } else { header = m.title + " " + m.spinner.View() } - if !m.showOutput { - return header - } - return header + errbuf.String() + "\n" + outbuf.String() + return header + "\n" + out } func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { From 64d69eb59bed32206a3c1f8bafada435aa1a4911 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 13 Dec 2024 16:59:14 -0300 Subject: [PATCH 095/198] feat(version): adds command to check current gum version (#775) * feat(version): adds command to check current gum version closes #352 Signed-off-by: Carlos Alexandro Becker * Update version/command.go Co-authored-by: Gareth Jones --------- Signed-off-by: Carlos Alexandro Becker Co-authored-by: Gareth Jones --- go.mod | 1 + go.sum | 2 ++ gum.go | 11 +++++++++++ main.go | 1 + version/command.go | 25 +++++++++++++++++++++++++ version/options.go | 6 ++++++ 6 files changed, 46 insertions(+) create mode 100644 version/command.go create mode 100644 version/options.go diff --git a/go.mod b/go.mod index 14d781e..dc913fd 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/charmbracelet/gum go 1.21 require ( + github.com/Masterminds/semver/v3 v3.3.1 github.com/alecthomas/kong v1.6.0 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 diff --git a/go.sum b/go.sum index a1c5b5b..8c72ddd 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= +github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4= +github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0= github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E= diff --git a/gum.go b/gum.go index 7a59f20..4191314 100644 --- a/gum.go +++ b/gum.go @@ -17,6 +17,7 @@ import ( "github.com/charmbracelet/gum/spin" "github.com/charmbracelet/gum/style" "github.com/charmbracelet/gum/table" + "github.com/charmbracelet/gum/version" "github.com/charmbracelet/gum/write" ) @@ -214,4 +215,14 @@ type Gum struct { // $ gum log --level info "Hello, world!" // Log log.Options `cmd:"" help:"Log messages to output"` + + // VersionCheck provides a command that checks if the current gum version + // matches a given semantic version constraint. + // + // It can be used to check that a minimum gum version is installed in a + // script. + // + // $ gum version-check '~> 0.15' + // + VersionCheck version.Options `cmd:"" help:"Semver check current gum version"` } diff --git a/main.go b/main.go index 75741e2..18fa9f0 100644 --- a/main.go +++ b/main.go @@ -54,6 +54,7 @@ func main() { }), kong.Vars{ "version": version, + "versionNumber": Version, "defaultHeight": "0", "defaultWidth": "0", "defaultAlign": "left", diff --git a/version/command.go b/version/command.go new file mode 100644 index 0000000..5102b34 --- /dev/null +++ b/version/command.go @@ -0,0 +1,25 @@ +package version + +import ( + "fmt" + + "github.com/Masterminds/semver/v3" + "github.com/alecthomas/kong" +) + +// Run check that a given version matches a semantic version constraint. +func (o Options) Run(ctx *kong.Context) error { + c, err := semver.NewConstraint(o.Constraint) + if err != nil { + return fmt.Errorf("could not parse range %s: %w", o.Constraint, err) + } + current := ctx.Model.Vars()["versionNumber"] + v, err := semver.NewVersion(current) + if err != nil { + return fmt.Errorf("could not parse version %s: %w", current, err) + } + if !c.Check(v) { + return fmt.Errorf("gum version %q is not within given range %q", current, o.Constraint) + } + return nil +} diff --git a/version/options.go b/version/options.go new file mode 100644 index 0000000..2dbb19d --- /dev/null +++ b/version/options.go @@ -0,0 +1,6 @@ +package version + +// Options is the set of options that can be used with version. +type Options struct { + Constraint string `arg:"" help:"Semantic version constraint"` +} From f230a3d5fc491b1464a8f847cad4725878dcf257 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 13 Dec 2024 16:59:32 -0300 Subject: [PATCH 096/198] feat(filter): allow to focus out of filter (#776) - esc focus out of the filter - esc with filter blurred quits - g/G/j/k navigation when filter is blurred closes #201 --- choose/choose.go | 1 - filter/filter.go | 49 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/choose/choose.go b/choose/choose.go index ff6cf5e..6594676 100644 --- a/choose/choose.go +++ b/choose/choose.go @@ -39,7 +39,6 @@ func defaultKeymap() keymap { ), End: key.NewBinding( key.WithKeys("G", "end"), - key.WithHelp("G", "end"), ), ToggleAll: key.NewBinding( key.WithKeys("a", "A", "ctrl+a"), diff --git a/filter/filter.go b/filter/filter.go index 23c0006..84f2b94 100644 --- a/filter/filter.go +++ b/filter/filter.go @@ -30,6 +30,18 @@ func defaultKeymap() keymap { Up: key.NewBinding( key.WithKeys("up", "ctrl+k", "ctrl+p"), ), + NDown: key.NewBinding( + key.WithKeys("j"), + ), + NUp: key.NewBinding( + key.WithKeys("k"), + ), + Home: key.NewBinding( + key.WithKeys("g", "home"), + ), + End: key.NewBinding( + key.WithKeys("G", "end"), + ), ToggleAndNext: key.NewBinding( key.WithKeys("tab"), key.WithHelp("tab", "toggle"), @@ -50,6 +62,14 @@ func defaultKeymap() keymap { key.WithHelp("ctrl+a", "select all"), key.WithDisabled(), ), + FocusInSearch: key.NewBinding( + key.WithKeys("/"), + key.WithHelp("/", "search"), + ), + FocusOutSearch: key.NewBinding( + key.WithKeys("esc"), + key.WithHelp("esc", "blur search"), + ), Quit: key.NewBinding( key.WithKeys("esc"), key.WithHelp("esc", "quit"), @@ -66,8 +86,14 @@ func defaultKeymap() keymap { } type keymap struct { + FocusInSearch, + FocusOutSearch, Down, Up, + NDown, + NUp, + Home, + End, ToggleAndNext, ToggleAndPrevious, ToggleAll, @@ -87,6 +113,8 @@ func (k keymap) ShortHelp() []key.Binding { key.WithKeys("up", "down"), key.WithHelp("↓↑", "navigate"), ), + k.FocusInSearch, + k.FocusOutSearch, k.ToggleAndNext, k.ToggleAll, k.Submit, @@ -262,6 +290,10 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case tea.KeyMsg: km := m.keymap switch { + case key.Matches(msg, km.FocusInSearch): + m.textinput.Focus() + case key.Matches(msg, km.FocusOutSearch): + m.textinput.Blur() case key.Matches(msg, km.Quit): m.quitting = true return m, tea.Quit @@ -272,10 +304,16 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.quitting = true m.submitted = true return m, tea.Quit - case key.Matches(msg, km.Down): + case key.Matches(msg, km.Down, km.NDown): m.CursorDown() - case key.Matches(msg, km.Up): + case key.Matches(msg, km.Up, km.NUp): m.CursorUp() + case key.Matches(msg, km.Home): + m.cursor = 0 + m.viewport.GotoTop() + case key.Matches(msg, km.End): + m.cursor = len(m.choices) - 1 + m.viewport.GotoBottom() case key.Matches(msg, km.ToggleAndNext): if m.limit == 1 { break // no op @@ -344,6 +382,13 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } } + m.keymap.FocusInSearch.SetEnabled(!m.textinput.Focused()) + m.keymap.FocusOutSearch.SetEnabled(m.textinput.Focused()) + m.keymap.NUp.SetEnabled(!m.textinput.Focused()) + m.keymap.NDown.SetEnabled(!m.textinput.Focused()) + m.keymap.Home.SetEnabled(!m.textinput.Focused()) + m.keymap.End.SetEnabled(!m.textinput.Focused()) + // It's possible that filtering items have caused fewer matches. So, ensure // that the selected index is within the bounds of the number of matches. m.cursor = clamp(0, len(m.matches)-1, m.cursor) From 966237b378e5fe17065fa7e9d9713f400dc3077e Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 13 Dec 2024 16:59:44 -0300 Subject: [PATCH 097/198] feat(filter): allow to pre-select items with --selected (#777) closes #593 --- filter/command.go | 23 +++++++++++++++++++---- filter/options.go | 1 + 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/filter/command.go b/filter/command.go index dfc8274..c933a05 100644 --- a/filter/command.go +++ b/filter/command.go @@ -86,7 +86,7 @@ func (o Options) Run() error { km.ToggleAll.SetEnabled(true) } - p := tea.NewProgram(model{ + m := model{ choices: o.Options, indicator: o.Indicator, matches: matches, @@ -112,14 +112,29 @@ func (o Options) Run() error { showHelp: o.ShowHelp, keymap: km, help: help.New(), - }, options...) + } - tm, err := p.Run() + for _, s := range o.Selected { + if o.NoLimit || o.Limit > 1 { + m.selected[s] = struct{}{} + } + } + + if len(o.Selected) > 0 { + for i, match := range matches { + if match.Str == o.Selected[0] { + m.cursor = i + break + } + } + } + + tm, err := tea.NewProgram(m, options...).Run() if err != nil { return fmt.Errorf("unable to run filter: %w", err) } - m := tm.(model) + m = tm.(model) if !m.submitted { return errors.New("nothing selected") } diff --git a/filter/options.go b/filter/options.go index 3cdefe8..7fab900 100644 --- a/filter/options.go +++ b/filter/options.go @@ -15,6 +15,7 @@ type Options struct { Limit int `help:"Maximum number of options to pick" default:"1" group:"Selection"` NoLimit bool `help:"Pick unlimited number of options (ignores limit)" group:"Selection"` SelectIfOne bool `help:"Select the given option if there is only one" group:"Selection"` + Selected []string `help:"Options that should start as selected (selects all if given '*')" default:"" env:"GUM_FILTER_SELECTED"` ShowHelp bool `help:"Show help keybinds" default:"true" negatable:"" env:"GUM_FILTER_SHOW_HELP"` Strict bool `help:"Only returns if anything matched. Otherwise return Filter" negatable:"" default:"true" group:"Selection"` SelectedPrefix string `help:"Character to indicate selected items (hidden if limit is 1)" default:" ◉ " env:"GUM_FILTER_SELECTED_PREFIX"` From 0e501ea47f97fbd4900bf850c246ede0d19301a4 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 13 Dec 2024 16:59:59 -0300 Subject: [PATCH 098/198] feat(filter): --select-if-one returns if single match (#778) closes #311 Signed-off-by: Carlos Alexandro Becker --- filter/command.go | 34 ++++++++++++---------------------- internal/tty/tty.go | 24 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 22 deletions(-) create mode 100644 internal/tty/tty.go diff --git a/filter/command.go b/filter/command.go index c933a05..c2a46cf 100644 --- a/filter/command.go +++ b/filter/command.go @@ -13,8 +13,7 @@ import ( "github.com/charmbracelet/gum/internal/files" "github.com/charmbracelet/gum/internal/stdin" "github.com/charmbracelet/gum/internal/timeout" - "github.com/charmbracelet/x/ansi" - "github.com/charmbracelet/x/term" + "github.com/charmbracelet/gum/internal/tty" "github.com/sahilm/fuzzy" ) @@ -44,11 +43,6 @@ func (o Options) Run() error { return errors.New("no options provided, see `gum filter --help`") } - if o.SelectIfOne && len(o.Options) == 1 { - fmt.Println(o.Options[0]) - return nil - } - ctx, cancel := timeout.Context(o.Timeout) defer cancel() @@ -74,11 +68,16 @@ func (o Options) Run() error { matches = matchAll(o.Options) } - km := defaultKeymap() - if o.NoLimit { o.Limit = len(o.Options) } + + if o.SelectIfOne && len(matches) == 1 { + tty.Println(matches[0].Str) + return nil + } + + km := defaultKeymap() if o.NoLimit || o.Limit > 1 { km.Toggle.SetEnabled(true) km.ToggleAndPrevious.SetEnabled(true) @@ -138,30 +137,21 @@ func (o Options) Run() error { if !m.submitted { return errors.New("nothing selected") } - isTTY := term.IsTerminal(os.Stdout.Fd()) // allSelections contains values only if limit is greater // than 1 or if flag --no-limit is passed, hence there is // no need to further checks if len(m.selected) > 0 { - o.checkSelected(m, isTTY) + o.checkSelected(m) } else if len(m.matches) > m.cursor && m.cursor >= 0 { - if isTTY { - fmt.Println(m.matches[m.cursor].Str) - } else { - fmt.Println(ansi.Strip(m.matches[m.cursor].Str)) - } + tty.Println(m.matches[m.cursor].Str) } return nil } -func (o Options) checkSelected(m model, isTTY bool) { +func (o Options) checkSelected(m model) { for k := range m.selected { - if isTTY { - fmt.Println(k) - } else { - fmt.Println(ansi.Strip(k)) - } + tty.Println(k) } } diff --git a/internal/tty/tty.go b/internal/tty/tty.go new file mode 100644 index 0000000..75b8237 --- /dev/null +++ b/internal/tty/tty.go @@ -0,0 +1,24 @@ +// Package tty provides tty-aware printing. +package tty + +import ( + "fmt" + "os" + "sync" + + "github.com/charmbracelet/x/ansi" + "github.com/charmbracelet/x/term" +) + +var isTTY = sync.OnceValue(func() bool { + return term.IsTerminal(os.Stdout.Fd()) +}) + +// Println handles println, striping ansi sequences if stdout is not a tty. +func Println(s string) { + if isTTY() { + fmt.Println(s) + return + } + fmt.Println(ansi.Strip(s)) +} From 6d405c49b1b929b771cda5fe939cf5900e392b70 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 13 Dec 2024 17:03:42 -0300 Subject: [PATCH 099/198] feat(choose,filter): --input-delimiter --output-delimiter (#779) * feat(choose,filter): --input-delimiter --output-delimiter allows to change how content from stdin is used, and how results are printed. one could get around it piping into and from `tr`, but results aren't quite right, especially when `tr '\n' ','` for example, as it'll add an extra `,` in the end of the string. This makes things a bit cleaner, hopefully. closes #274 * fix: use new tty pkg --- choose/command.go | 19 ++++++------------- choose/options.go | 2 ++ filter/command.go | 6 ++++-- filter/options.go | 2 ++ 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/choose/command.go b/choose/command.go index ea9faf7..92a5752 100644 --- a/choose/command.go +++ b/choose/command.go @@ -13,9 +13,8 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/gum/internal/stdin" "github.com/charmbracelet/gum/internal/timeout" + "github.com/charmbracelet/gum/internal/tty" "github.com/charmbracelet/lipgloss" - "github.com/charmbracelet/x/ansi" - "github.com/charmbracelet/x/term" ) // Run provides a shell script interface for choosing between different through @@ -31,7 +30,7 @@ func (o Options) Run() error { if input == "" { return errors.New("no options provided, see `gum choose --help`") } - o.Options = strings.Split(input, "\n") + o.Options = strings.Split(input, o.InputDelimiter) } if o.SelectIfOne && len(o.Options) == 1 { @@ -146,19 +145,13 @@ func (o Options) Run() error { return m.items[i].order < m.items[j].order }) } - var s strings.Builder + + var out []string for _, item := range m.items { if item.selected { - s.WriteString(item.text) - s.WriteRune('\n') + out = append(out, item.text) } } - - if term.IsTerminal(os.Stdout.Fd()) { - fmt.Print(s.String()) - } else { - fmt.Print(ansi.Strip(s.String())) - } - + tty.Println(strings.Join(out, o.OutputDelimiter)) return nil } diff --git a/choose/options.go b/choose/options.go index ec44134..4777ef0 100644 --- a/choose/options.go +++ b/choose/options.go @@ -22,6 +22,8 @@ type Options struct { UnselectedPrefix string `help:"Prefix to show on unselected items (hidden if limit is 1)" default:"• " env:"GUM_CHOOSE_UNSELECTED_PREFIX"` Selected []string `help:"Options that should start as selected (selects all if given '*')" default:"" env:"GUM_CHOOSE_SELECTED"` SelectIfOne bool `help:"Select the given option if there is only one" group:"Selection"` + InputDelimiter string `help:"Option delimiter when reading from STDIN" default:"\n" env:"GUM_CHOOSE_INPUT_DELIMITER"` + OutputDelimiter string `help:"Option delimiter when writing to STDOUT" default:"\n" env:"GUM_CHOOSE_OUTPUT_DELIMITER"` CursorStyle style.Styles `embed:"" prefix:"cursor." set:"defaultForeground=212" envprefix:"GUM_CHOOSE_CURSOR_"` HeaderStyle style.Styles `embed:"" prefix:"header." set:"defaultForeground=99" envprefix:"GUM_CHOOSE_HEADER_"` diff --git a/filter/command.go b/filter/command.go index c2a46cf..2c6b9b0 100644 --- a/filter/command.go +++ b/filter/command.go @@ -33,7 +33,7 @@ func (o Options) Run() error { if len(o.Options) == 0 { if input, _ := stdin.ReadStrip(); input != "" { - o.Options = strings.Split(input, "\n") + o.Options = strings.Split(input, o.InputDelimiter) } else { o.Options = files.List() } @@ -151,7 +151,9 @@ func (o Options) Run() error { } func (o Options) checkSelected(m model) { + out := []string{} for k := range m.selected { - tty.Println(k) + out = append(out, k) } + tty.Println(strings.Join(out, o.OutputDelimiter)) } diff --git a/filter/options.go b/filter/options.go index 7fab900..b439b37 100644 --- a/filter/options.go +++ b/filter/options.go @@ -38,6 +38,8 @@ type Options struct { Fuzzy bool `help:"Enable fuzzy matching; otherwise match from start of word" default:"true" env:"GUM_FILTER_FUZZY" negatable:""` FuzzySort bool `help:"Sort fuzzy results by their scores" default:"true" env:"GUM_FILTER_FUZZY_SORT" negatable:""` Timeout time.Duration `help:"Timeout until filter command aborts" default:"0s" env:"GUM_FILTER_TIMEOUT"` + InputDelimiter string `help:"Option delimiter when reading from STDIN" default:"\n" env:"GUM_FILTER_INPUT_DELIMITER"` + OutputDelimiter string `help:"Option delimiter when writing to STDOUT" default:"\n" env:"GUM_FILTER_OUTPUT_DELIMITER"` // Deprecated: use [FuzzySort]. This will be removed at some point. Sort bool `help:"Sort fuzzy results by their scores" default:"true" env:"GUM_FILTER_FUZZY_SORT" negatable:"" hidden:""` From 2e321f57e245147fe55ee58ef9c046db91b76e17 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 17 Dec 2024 09:47:31 -0300 Subject: [PATCH 100/198] feat(choose): label delimiters (#783) I'm not sure if I like this impl, but it does work. closes #406 --- choose/command.go | 22 ++++++++++++++++++++-- choose/options.go | 1 + go.mod | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/choose/command.go b/choose/command.go index 92a5752..285eb16 100644 --- a/choose/command.go +++ b/choose/command.go @@ -3,6 +3,7 @@ package choose import ( "errors" "fmt" + "maps" "os" "slices" "sort" @@ -33,8 +34,25 @@ func (o Options) Run() error { o.Options = strings.Split(input, o.InputDelimiter) } + // normalize options into a map + options := map[string]string{} + for _, opt := range o.Options { + if o.LabelDelimiter == "" { + options[opt] = opt + continue + } + label, value, ok := strings.Cut(opt, o.LabelDelimiter) + if !ok { + return fmt.Errorf("invalid option format: %q", opt) + } + options[label] = value + } + if o.LabelDelimiter != "" { + o.Options = slices.Collect(maps.Keys(options)) + } + if o.SelectIfOne && len(o.Options) == 1 { - fmt.Println(o.Options[0]) + fmt.Println(options[o.Options[0]]) return nil } @@ -149,7 +167,7 @@ func (o Options) Run() error { var out []string for _, item := range m.items { if item.selected { - out = append(out, item.text) + out = append(out, options[item.text]) } } tty.Println(strings.Join(out, o.OutputDelimiter)) diff --git a/choose/options.go b/choose/options.go index 4777ef0..0f21a43 100644 --- a/choose/options.go +++ b/choose/options.go @@ -24,6 +24,7 @@ type Options struct { SelectIfOne bool `help:"Select the given option if there is only one" group:"Selection"` InputDelimiter string `help:"Option delimiter when reading from STDIN" default:"\n" env:"GUM_CHOOSE_INPUT_DELIMITER"` OutputDelimiter string `help:"Option delimiter when writing to STDOUT" default:"\n" env:"GUM_CHOOSE_OUTPUT_DELIMITER"` + LabelDelimiter string `help:"Allows to set a delimiter, so options can be set as label:value" default:"" env:"GUM_CHOOSE_LABEL_DELIMITER"` CursorStyle style.Styles `embed:"" prefix:"cursor." set:"defaultForeground=212" envprefix:"GUM_CHOOSE_CURSOR_"` HeaderStyle style.Styles `embed:"" prefix:"header." set:"defaultForeground=99" envprefix:"GUM_CHOOSE_HEADER_"` diff --git a/go.mod b/go.mod index dc913fd..9614f93 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/charmbracelet/gum -go 1.21 +go 1.23.0 require ( github.com/Masterminds/semver/v3 v3.3.1 From 4cedf9fca0082fc78f381cb78f619fbc51e271df Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 17 Dec 2024 13:56:19 -0300 Subject: [PATCH 101/198] feat: --no-strip-ansi (#784) Signed-off-by: Carlos Alexandro Becker Co-authored-by: Sridaran Thoniyil --- choose/command.go | 2 +- choose/options.go | 1 + filter/command.go | 2 +- filter/options.go | 1 + format/command.go | 2 +- format/options.go | 2 ++ input/command.go | 4 +-- input/options.go | 1 + internal/stdin/stdin.go | 54 ++++++++++++++++++++++++++++++++++------- style/command.go | 2 +- style/options.go | 7 +++--- write/command.go | 2 +- write/options.go | 1 + 13 files changed, 62 insertions(+), 19 deletions(-) diff --git a/choose/command.go b/choose/command.go index 285eb16..9a621a2 100644 --- a/choose/command.go +++ b/choose/command.go @@ -27,7 +27,7 @@ func (o Options) Run() error { ) if len(o.Options) <= 0 { - input, _ := stdin.ReadStrip() + input, _ := stdin.Read(stdin.StripANSI(o.StripANSI)) if input == "" { return errors.New("no options provided, see `gum choose --help`") } diff --git a/choose/options.go b/choose/options.go index 0f21a43..e5ea6b2 100644 --- a/choose/options.go +++ b/choose/options.go @@ -25,6 +25,7 @@ type Options struct { InputDelimiter string `help:"Option delimiter when reading from STDIN" default:"\n" env:"GUM_CHOOSE_INPUT_DELIMITER"` OutputDelimiter string `help:"Option delimiter when writing to STDOUT" default:"\n" env:"GUM_CHOOSE_OUTPUT_DELIMITER"` LabelDelimiter string `help:"Allows to set a delimiter, so options can be set as label:value" default:"" env:"GUM_CHOOSE_LABEL_DELIMITER"` + StripANSI bool `help:"Strip ANSI sequences when reading from STDIN" default:"true" negatable:"" env:"GUM_CHOOSE_STRIP_ANSI"` CursorStyle style.Styles `embed:"" prefix:"cursor." set:"defaultForeground=212" envprefix:"GUM_CHOOSE_CURSOR_"` HeaderStyle style.Styles `embed:"" prefix:"header." set:"defaultForeground=99" envprefix:"GUM_CHOOSE_HEADER_"` diff --git a/filter/command.go b/filter/command.go index 2c6b9b0..12ad497 100644 --- a/filter/command.go +++ b/filter/command.go @@ -32,7 +32,7 @@ func (o Options) Run() error { v := viewport.New(o.Width, o.Height) if len(o.Options) == 0 { - if input, _ := stdin.ReadStrip(); input != "" { + if input, _ := stdin.Read(stdin.StripANSI(o.StripANSI)); input != "" { o.Options = strings.Split(input, o.InputDelimiter) } else { o.Options = files.List() diff --git a/filter/options.go b/filter/options.go index b439b37..07c50ce 100644 --- a/filter/options.go +++ b/filter/options.go @@ -40,6 +40,7 @@ type Options struct { Timeout time.Duration `help:"Timeout until filter command aborts" default:"0s" env:"GUM_FILTER_TIMEOUT"` InputDelimiter string `help:"Option delimiter when reading from STDIN" default:"\n" env:"GUM_FILTER_INPUT_DELIMITER"` OutputDelimiter string `help:"Option delimiter when writing to STDOUT" default:"\n" env:"GUM_FILTER_OUTPUT_DELIMITER"` + StripANSI bool `help:"Strip ANSI sequences when reading from STDIN" default:"true" negatable:"" env:"GUM_FILTER_STRIP_ANSI"` // Deprecated: use [FuzzySort]. This will be removed at some point. Sort bool `help:"Sort fuzzy results by their scores" default:"true" env:"GUM_FILTER_FUZZY_SORT" negatable:"" hidden:""` diff --git a/format/command.go b/format/command.go index 4cea2d9..3217f0e 100644 --- a/format/command.go +++ b/format/command.go @@ -24,7 +24,7 @@ func (o Options) Run() error { if len(o.Template) > 0 { input = strings.Join(o.Template, "\n") } else { - input, _ = stdin.ReadStrip() + input, _ = stdin.Read(stdin.StripANSI(o.StripANSI)) } switch o.Type { diff --git a/format/options.go b/format/options.go index 6f36dcd..ee87f95 100644 --- a/format/options.go +++ b/format/options.go @@ -6,5 +6,7 @@ type Options struct { Theme string `help:"Glamour theme to use for markdown formatting" default:"pink" env:"GUM_FORMAT_THEME"` Language string `help:"Programming language to parse code" short:"l" default:"" env:"GUM_FORMAT_LANGUAGE"` + StripANSI bool `help:"Strip ANSI sequences when reading from STDIN" default:"true" negatable:"" env:"GUM_FORMAT_STRIP_ANSI"` + Type string `help:"Format to use (markdown,template,code,emoji)" enum:"markdown,template,code,emoji" short:"t" default:"markdown" env:"GUM_FORMAT_TYPE"` } diff --git a/input/command.go b/input/command.go index 05dc1e3..7d96e72 100644 --- a/input/command.go +++ b/input/command.go @@ -17,7 +17,7 @@ import ( // https://github.com/charmbracelet/bubbles/textinput func (o Options) Run() error { if o.Value == "" { - if in, _ := stdin.ReadStrip(); in != "" { + if in, _ := stdin.Read(stdin.StripANSI(o.StripANSI)); in != "" { o.Value = in } } @@ -25,7 +25,7 @@ func (o Options) Run() error { i := textinput.New() if o.Value != "" { i.SetValue(o.Value) - } else if in, _ := stdin.ReadStrip(); in != "" { + } else if in, _ := stdin.Read(stdin.StripANSI(o.StripANSI)); in != "" { i.SetValue(in) } i.Focus() diff --git a/input/options.go b/input/options.go index 2df85e7..7463adb 100644 --- a/input/options.go +++ b/input/options.go @@ -22,4 +22,5 @@ type Options struct { Header string `help:"Header value" default:"" env:"GUM_INPUT_HEADER"` HeaderStyle style.Styles `embed:"" prefix:"header." set:"defaultForeground=240" envprefix:"GUM_INPUT_HEADER_"` Timeout time.Duration `help:"Timeout until input aborts" default:"0s" env:"GUM_INPUT_TIMEOUT"` + StripANSI bool `help:"Strip ANSI sequences when reading from STDIN" default:"true" negatable:"" env:"GUM_INPUT_STRIP_ANSI"` } diff --git a/internal/stdin/stdin.go b/internal/stdin/stdin.go index a5cebdb..42b0162 100644 --- a/internal/stdin/stdin.go +++ b/internal/stdin/stdin.go @@ -10,16 +10,54 @@ import ( "github.com/charmbracelet/x/ansi" ) +type options struct { + ansiStrip bool + singleLine bool +} + +// Option is a read option. +type Option func(*options) + +// StripANSI optionally strips ansi sequences. +func StripANSI(b bool) Option { + return func(o *options) { + o.ansiStrip = b + } +} + +// SingleLine reads a single line. +func SingleLine(b bool) Option { + return func(o *options) { + o.singleLine = b + } +} + // Read reads input from an stdin pipe. -func Read() (string, error) { +func Read(opts ...Option) (string, error) { if IsEmpty() { return "", fmt.Errorf("stdin is empty") } + options := options{} + for _, opt := range opts { + opt(&options) + } + reader := bufio.NewReader(os.Stdin) var b strings.Builder - for { + if options.singleLine { + line, _, err := reader.ReadLine() + if err != nil { + return "", fmt.Errorf("failed to read line: %w", err) + } + _, err = b.Write(line) + if err != nil { + return "", fmt.Errorf("failed to write: %w", err) + } + } + + for !options.singleLine { r, _, err := reader.ReadRune() if err != nil && err == io.EOF { break @@ -30,13 +68,11 @@ func Read() (string, error) { } } - return strings.TrimSpace(b.String()), nil -} - -// ReadStrip reads input from an stdin pipe and strips ansi sequences. -func ReadStrip() (string, error) { - s, err := Read() - return ansi.Strip(s), err + s := strings.TrimSpace(b.String()) + if options.ansiStrip { + return ansi.Strip(s), nil + } + return s, nil } // IsEmpty returns whether stdin is empty. diff --git a/style/command.go b/style/command.go index be04c84..0263211 100644 --- a/style/command.go +++ b/style/command.go @@ -20,7 +20,7 @@ func (o Options) Run() error { if len(o.Text) > 0 { text = strings.Join(o.Text, "\n") } else { - text, _ = stdin.ReadStrip() + text, _ = stdin.Read(stdin.StripANSI(o.StripANSI)) if text == "" { return errors.New("no input provided, see `gum style --help`") } diff --git a/style/options.go b/style/options.go index cd2251d..67545e5 100644 --- a/style/options.go +++ b/style/options.go @@ -2,9 +2,10 @@ package style // Options is the customization options for the style command. type Options struct { - Text []string `arg:"" optional:"" help:"Text to which to apply the style"` - Trim bool `help:"Trim whitespaces on every input line" default:"false"` - Style StylesNotHidden `embed:""` + Text []string `arg:"" optional:"" help:"Text to which to apply the style"` + Trim bool `help:"Trim whitespaces on every input line" default:"false"` + StripANSI bool `help:"Strip ANSI sequences when reading from STDIN" default:"true" negatable:"" env:"GUM_STYLE_STRIP_ANSI"` + Style StylesNotHidden `embed:""` } // Styles is a flag set of possible styles. diff --git a/write/command.go b/write/command.go index 34669cb..548cd95 100644 --- a/write/command.go +++ b/write/command.go @@ -17,7 +17,7 @@ import ( // Run provides a shell script interface for the text area bubble. // https://github.com/charmbracelet/bubbles/textarea func (o Options) Run() error { - in, _ := stdin.ReadStrip() + in, _ := stdin.Read(stdin.StripANSI(o.StripANSI)) if in != "" && o.Value == "" { o.Value = strings.ReplaceAll(in, "\r", "") } diff --git a/write/options.go b/write/options.go index 96ae7a8..16653eb 100644 --- a/write/options.go +++ b/write/options.go @@ -21,6 +21,7 @@ type Options struct { ShowHelp bool `help:"Show help key binds" negatable:"" default:"true" env:"GUM_WRITE_SHOW_HELP"` CursorMode string `prefix:"cursor." name:"mode" help:"Cursor mode" default:"blink" enum:"blink,hide,static" env:"GUM_WRITE_CURSOR_MODE"` Timeout time.Duration `help:"Timeout until choose returns selected element" default:"0s" env:"GUM_WRITE_TIMEOUT"` + StripANSI bool `help:"Strip ANSI sequences when reading from STDIN" default:"true" negatable:"" env:"GUM_WRITE_STRIP_ANSI"` BaseStyle style.Styles `embed:"" prefix:"base." envprefix:"GUM_WRITE_BASE_"` CursorLineNumberStyle style.Styles `embed:"" prefix:"cursor-line-number." set:"defaultForeground=7" envprefix:"GUM_WRITE_CURSOR_LINE_NUMBER_"` From 0b89ff82d4cdcd59e5303df5fb5cc05fc83cc270 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 17 Dec 2024 14:17:43 -0300 Subject: [PATCH 102/198] feat: yes|gum confirm (#772) * feat: yes|gum confirm Signed-off-by: Carlos Alexandro Becker * fix: rebase on main --------- Signed-off-by: Carlos Alexandro Becker --- confirm/command.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/confirm/command.go b/confirm/command.go index ac151ad..103fbad 100644 --- a/confirm/command.go +++ b/confirm/command.go @@ -7,12 +7,25 @@ import ( "github.com/charmbracelet/bubbles/help" tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/gum/internal/stdin" "github.com/charmbracelet/gum/internal/timeout" ) +var errNotConfirmed = errors.New("not confirmed") + // Run provides a shell script interface for prompting a user to confirm an // action with an affirmative or negative answer. func (o Options) Run() error { + line, err := stdin.Read(stdin.SingleLine(true)) + if err == nil { + switch line { + case "yes", "y": + return nil + default: + return errNotConfirmed + } + } + ctx, cancel := timeout.Context(o.Timeout) defer cancel() @@ -52,5 +65,5 @@ func (o Options) Run() error { return nil } - return errors.New("not confirmed") + return errNotConfirmed } From 0f8f67f96e52159bc9645a9ffab4004658e4fdc6 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 17 Dec 2024 14:43:24 -0300 Subject: [PATCH 103/198] feat(choose): select from stdin (#773) Signed-off-by: Carlos Alexandro Becker --- choose/command.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/choose/command.go b/choose/command.go index 9a621a2..47e3549 100644 --- a/choose/command.go +++ b/choose/command.go @@ -26,8 +26,10 @@ func (o Options) Run() error { verySubduedStyle = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "#DDDADA", Dark: "#3C3C3C"}) ) - if len(o.Options) <= 0 { - input, _ := stdin.Read(stdin.StripANSI(o.StripANSI)) + input, _ := stdin.Read(stdin.StripANSI(o.StripANSI)) + if len(o.Options) > 0 && len(o.Selected) == 0 { + o.Selected = strings.Split(input, o.InputDelimiter) + } else if len(o.Options) == 0 { if input == "" { return errors.New("no options provided, see `gum choose --help`") } From cd151b51bf8758598602759be3a076af1c798ec2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 Jan 2025 05:00:57 +0000 Subject: [PATCH 104/198] chore(deps): bump github.com/alecthomas/kong from 1.6.0 to 1.6.1 (#790) Bumps [github.com/alecthomas/kong](https://github.com/alecthomas/kong) from 1.6.0 to 1.6.1. - [Release notes](https://github.com/alecthomas/kong/releases) - [Commits](https://github.com/alecthomas/kong/compare/v1.6.0...v1.6.1) --- updated-dependencies: - dependency-name: github.com/alecthomas/kong dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9614f93..4cbbdda 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.23.0 require ( github.com/Masterminds/semver/v3 v3.3.1 - github.com/alecthomas/kong v1.6.0 + github.com/alecthomas/kong v1.6.1 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 github.com/charmbracelet/bubbletea v1.2.5-0.20241207142916-e0515bc22ad1 diff --git a/go.sum b/go.sum index 8c72ddd..ddbaf90 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8v github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E= github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I= -github.com/alecthomas/kong v1.6.0 h1:mwOzbdMR7uv2vul9J0FU3GYxE7ls/iX1ieMg5WIM6gE= -github.com/alecthomas/kong v1.6.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= +github.com/alecthomas/kong v1.6.1 h1:/7bVimARU3uxPD0hbryPE8qWrS3Oz3kPQoxA/H2NKG8= +github.com/alecthomas/kong v1.6.1/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= github.com/alecthomas/mango-kong v0.1.0 h1:iFVfP1k1K4qpml3JUQmD5I8MCQYfIvsD9mRdrw7jJC4= github.com/alecthomas/mango-kong v0.1.0/go.mod h1:t+TYVdsONUolf/BwVcm+15eqcdAj15h4Qe9MMFAwwT4= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= From d3d20efc7030a2344328e6d74d18c48b1f81f5fa Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 7 Jan 2025 11:08:24 -0300 Subject: [PATCH 105/198] fix(filter): properly handle options with ansi styles (#789) * fix(filter): handle styles option matches * perf: use ranges * fix: cut * fix: ansi update --- filter/command.go | 18 +++++++--- filter/filter.go | 80 ++++++++++++++++++++++++++++++------------- filter/filter_test.go | 41 ++++++++++++++++++++++ go.mod | 2 +- go.sum | 4 +-- 5 files changed, 114 insertions(+), 31 deletions(-) create mode 100644 filter/filter_test.go diff --git a/filter/command.go b/filter/command.go index 12ad497..39bc8e8 100644 --- a/filter/command.go +++ b/filter/command.go @@ -14,6 +14,7 @@ import ( "github.com/charmbracelet/gum/internal/stdin" "github.com/charmbracelet/gum/internal/timeout" "github.com/charmbracelet/gum/internal/tty" + "github.com/charmbracelet/x/ansi" "github.com/sahilm/fuzzy" ) @@ -59,13 +60,21 @@ func (o Options) Run() error { if o.Value != "" { i.SetValue(o.Value) } + + choices := map[string]string{} + filteringChoices := []string{} + for _, opt := range o.Options { + s := ansi.Strip(opt) + choices[s] = opt + filteringChoices = append(filteringChoices, s) + } switch { case o.Value != "" && o.Fuzzy: - matches = fuzzy.Find(o.Value, o.Options) + matches = fuzzy.Find(o.Value, filteringChoices) case o.Value != "" && !o.Fuzzy: - matches = exactMatches(o.Value, o.Options) + matches = exactMatches(o.Value, filteringChoices) default: - matches = matchAll(o.Options) + matches = matchAll(filteringChoices) } if o.NoLimit { @@ -86,7 +95,8 @@ func (o Options) Run() error { } m := model{ - choices: o.Options, + choices: choices, + filteringChoices: filteringChoices, indicator: o.Indicator, matches: matches, header: o.Header, diff --git a/filter/filter.go b/filter/filter.go index 84f2b94..0a9bdc6 100644 --- a/filter/filter.go +++ b/filter/filter.go @@ -19,6 +19,7 @@ import ( "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/x/ansi" "github.com/sahilm/fuzzy" ) @@ -124,7 +125,8 @@ func (k keymap) ShortHelp() []key.Binding { type model struct { textinput textinput.Model viewport *viewport.Model - choices []string + choices map[string]string + filteringChoices []string matches []fuzzy.Match cursor int header string @@ -201,28 +203,37 @@ func (m model) View() string { s.WriteString(" ") } - // For this match, there are a certain number of characters that have - // caused the match. i.e. fuzzy matching. - // We should indicate to the users which characters are being matched. - mi := 0 - var buf strings.Builder - for ci, c := range match.Str { - // Check if the current character index matches the current matched - // index. If so, color the character to indicate a match. - if mi < len(match.MatchedIndexes) && ci == match.MatchedIndexes[mi] { - // Flush text buffer. - s.WriteString(lineTextStyle.Render(buf.String())) - buf.Reset() - - s.WriteString(m.matchStyle.Render(string(c))) - // We have matched this character, so we never have to check it - // again. Move on to the next match. - mi++ - } else { - // Not a match, buffer a regular character. - buf.WriteRune(c) - } + styledOption := m.choices[match.Str] + if len(match.MatchedIndexes) == 0 { + // No matches, just render the text. + s.WriteString(lineTextStyle.Render(styledOption)) + s.WriteRune('\n') + continue } + + // Use ansi.Truncate and ansi.TruncateLeft and ansi.StringWidth to + // style match.MatchedIndexes without losing the original option style: + var buf strings.Builder + lastIdx := 0 + for _, rng := range matchedRanges(match.MatchedIndexes) { + // fmt.Print("here ", lastIdx, rng, " - ", match.Str[rng[0]:rng[1]+1], "\r\n") + // Add the text before this match + if rng[0] > lastIdx { + buf.WriteString(ansi.Cut(styledOption, lastIdx, rng[0])) + } + + // Add the matched character with highlight + buf.WriteString(m.matchStyle.Render(match.Str[rng[0] : rng[1]+1])) + lastIdx = rng[1] + 1 + } + + // Add any remaining text after the last match + // fmt.Print("here ", lastIdx, ansi.StringWidth(styledOption), len(match.Str), "\r\n") + if lastIdx < ansi.StringWidth(styledOption) { + remaining := ansi.TruncateLeft(styledOption, lastIdx, "") + buf.WriteString(remaining) + } + // Flush text buffer. s.WriteString(lineTextStyle.Render(buf.String())) @@ -356,7 +367,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if !m.strict { choices = append(choices, m.textinput.Value()) } - choices = append(choices, m.choices...) + choices = append(choices, m.filteringChoices...) if m.fuzzy { if m.sort { m.matches = fuzzy.Find(m.textinput.Value(), choices) @@ -370,7 +381,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { // If the search field is empty, let's not display the matches // (none), but rather display all possible choices. if m.textinput.Value() == "" { - m.matches = matchAll(m.choices) + m.matches = matchAll(m.filteringChoices) } // For reverse layout, we need to offset the viewport so that the @@ -511,3 +522,24 @@ func clamp(low, high, val int) int { } return val } + +func matchedRanges(in []int) [][2]int { + if len(in) == 0 { + return [][2]int{} + } + current := [2]int{in[0], in[0]} + if len(in) == 1 { + return [][2]int{current} + } + var out [][2]int + for i := 1; i < len(in); i++ { + if in[i] == current[1]+1 { + current[1] = in[i] + } else { + out = append(out, current) + current = [2]int{in[i], in[i]} + } + } + out = append(out, current) + return out +} diff --git a/filter/filter_test.go b/filter/filter_test.go new file mode 100644 index 0000000..56e7590 --- /dev/null +++ b/filter/filter_test.go @@ -0,0 +1,41 @@ +package filter + +import ( + "reflect" + "testing" +) + +func TestMatchedRanges(t *testing.T) { + for name, tt := range map[string]struct { + in []int + out [][2]int + }{ + "empty": { + in: []int{}, + out: [][2]int{}, + }, + "one char": { + in: []int{1}, + out: [][2]int{{1, 1}}, + }, + "2 char range": { + in: []int{1, 2}, + out: [][2]int{{1, 2}}, + }, + "multiple char range": { + in: []int{1, 2, 3, 4, 5, 6}, + out: [][2]int{{1, 6}}, + }, + "multiple char ranges": { + in: []int{1, 2, 3, 5, 6, 10, 11, 12, 13, 23, 24, 40, 42, 43, 45, 52}, + out: [][2]int{{1, 3}, {5, 6}, {10, 13}, {23, 24}, {40, 40}, {42, 43}, {45, 45}, {52, 52}}, + }, + } { + t.Run(name, func(t *testing.T) { + match := matchedRanges(tt.in) + if !reflect.DeepEqual(match, tt.out) { + t.Errorf("expected %v, got %v", tt.out, match) + } + }) + } +} diff --git a/go.mod b/go.mod index 4cbbdda..489e32a 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/lipgloss v1.0.0 github.com/charmbracelet/log v0.4.0 - github.com/charmbracelet/x/ansi v0.6.0 + github.com/charmbracelet/x/ansi v0.6.1-0.20250107110353-48b574af22a5 github.com/charmbracelet/x/editor v0.1.0 github.com/charmbracelet/x/term v0.2.1 github.com/muesli/reflow v0.3.0 diff --git a/go.sum b/go.sum index ddbaf90..88954fb 100644 --- a/go.sum +++ b/go.sum @@ -30,8 +30,8 @@ github.com/charmbracelet/lipgloss v1.0.0 h1:O7VkGDvqEdGi93X+DeqsQ7PKHDgtQfF8j8/O github.com/charmbracelet/lipgloss v1.0.0/go.mod h1:U5fy9Z+C38obMs+T+tJqst9VGzlOYGj4ri9reL3qUlo= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= -github.com/charmbracelet/x/ansi v0.6.0 h1:qOznutrb93gx9oMiGf7caF7bqqubh6YIM0SWKyA08pA= -github.com/charmbracelet/x/ansi v0.6.0/go.mod h1:KBUFw1la39nl0dLl10l5ORDAqGXaeurTQmwyyVKse/Q= +github.com/charmbracelet/x/ansi v0.6.1-0.20250107110353-48b574af22a5 h1:TSjbA80sXnABV/Vxhnb67Ho7p8bEYqz6NIdhLAx+1yg= +github.com/charmbracelet/x/ansi v0.6.1-0.20250107110353-48b574af22a5/go.mod h1:KBUFw1la39nl0dLl10l5ORDAqGXaeurTQmwyyVKse/Q= github.com/charmbracelet/x/editor v0.1.0 h1:p69/dpvlwRTs9uYiPeAWruwsHqTFzHhTvQOd/WVSX98= github.com/charmbracelet/x/editor v0.1.0/go.mod h1:oivrEbcP/AYt/Hpvk5pwDXXrQ933gQS6UzL6fxqAGSA= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q= From da325ae345db4312be568abc2e4af71cefce6a27 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 7 Jan 2025 11:28:17 -0300 Subject: [PATCH 106/198] fix(filter): wide chars Signed-off-by: Carlos Alexandro Becker --- filter/filter.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/filter/filter.go b/filter/filter.go index 0a9bdc6..0c72023 100644 --- a/filter/filter.go +++ b/filter/filter.go @@ -211,10 +211,11 @@ func (m model) View() string { continue } - // Use ansi.Truncate and ansi.TruncateLeft and ansi.StringWidth to - // style match.MatchedIndexes without losing the original option style: var buf strings.Builder lastIdx := 0 + + // Use ansi.Truncate and ansi.TruncateLeft and ansi.StringWidth to + // style match.MatchedIndexes without losing the original option style: for _, rng := range matchedRanges(match.MatchedIndexes) { // fmt.Print("here ", lastIdx, rng, " - ", match.Str[rng[0]:rng[1]+1], "\r\n") // Add the text before this match @@ -223,16 +224,12 @@ func (m model) View() string { } // Add the matched character with highlight - buf.WriteString(m.matchStyle.Render(match.Str[rng[0] : rng[1]+1])) + buf.WriteString(m.matchStyle.Render(ansi.Cut(match.Str, rng[0], rng[1]+1))) lastIdx = rng[1] + 1 } // Add any remaining text after the last match - // fmt.Print("here ", lastIdx, ansi.StringWidth(styledOption), len(match.Str), "\r\n") - if lastIdx < ansi.StringWidth(styledOption) { - remaining := ansi.TruncateLeft(styledOption, lastIdx, "") - buf.WriteString(remaining) - } + buf.WriteString(ansi.TruncateLeft(styledOption, lastIdx, "")) // Flush text buffer. s.WriteString(lineTextStyle.Render(buf.String())) From b0ec3a7915dc0c8ff65de084c9e633502d8c2eb8 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Sun, 12 Jan 2025 17:40:44 -0300 Subject: [PATCH 107/198] fix(filter): select all refs https://github.com/charmbracelet/gum/pull/777#issuecomment-2585836624 Signed-off-by: Carlos Alexandro Becker --- filter/command.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/filter/command.go b/filter/command.go index 39bc8e8..efe3f29 100644 --- a/filter/command.go +++ b/filter/command.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "os" + "slices" "strings" "github.com/charmbracelet/bubbles/help" @@ -123,17 +124,19 @@ func (o Options) Run() error { help: help.New(), } - for _, s := range o.Selected { - if o.NoLimit || o.Limit > 1 { - m.selected[s] = struct{}{} - } - } - + isSelectAll := len(o.Selected) == 1 && o.Selected[0] == "*" + currentSelected := 0 if len(o.Selected) > 0 { - for i, match := range matches { - if match.Str == o.Selected[0] { + for i, option := range o.Options { + if currentSelected >= o.Limit || (!isSelectAll && !slices.Contains(o.Selected, option)) { + continue + } + if o.Limit == 1 { m.cursor = i - break + m.selected[option] = struct{}{} + } else { + currentSelected++ + m.selected[option] = struct{}{} } } } From bb34c45fe17ac651b2c4658eb615ea59c306572f Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Sun, 12 Jan 2025 17:42:52 -0300 Subject: [PATCH 108/198] fix(filter): take pre-filtering into account --- filter/command.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/filter/command.go b/filter/command.go index efe3f29..4185100 100644 --- a/filter/command.go +++ b/filter/command.go @@ -127,16 +127,16 @@ func (o Options) Run() error { isSelectAll := len(o.Selected) == 1 && o.Selected[0] == "*" currentSelected := 0 if len(o.Selected) > 0 { - for i, option := range o.Options { - if currentSelected >= o.Limit || (!isSelectAll && !slices.Contains(o.Selected, option)) { + for i, option := range matches { + if currentSelected >= o.Limit || (!isSelectAll && !slices.Contains(o.Selected, option.Str)) { continue } if o.Limit == 1 { m.cursor = i - m.selected[option] = struct{}{} + m.selected[option.Str] = struct{}{} } else { currentSelected++ - m.selected[option] = struct{}{} + m.selected[option.Str] = struct{}{} } } } From 89d495292b17cb9404508419519e963c0592ce0f Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Mon, 13 Jan 2025 13:49:43 -0500 Subject: [PATCH 109/198] chore(file): remove extra newline above help --- file/file.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/file/file.go b/file/file.go index 17ad144..a9878af 100644 --- a/file/file.go +++ b/file/file.go @@ -107,5 +107,5 @@ func (m model) View() string { } func (m model) helpView() string { - return "\n" + m.help.View(m.keymap) + return m.help.View(m.keymap) } From c93da09e1377a3dc092a3d5c2793eb3e313b9d91 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 19:31:05 +0000 Subject: [PATCH 110/198] chore(deps): bump golang.org/x/net from 0.27.0 to 0.33.0 (#798) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.27.0 to 0.33.0. - [Commits](https://github.com/golang/net/compare/v0.27.0...v0.33.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 489e32a..4004221 100644 --- a/go.mod +++ b/go.mod @@ -43,8 +43,8 @@ require ( github.com/yuin/goldmark v1.7.4 // indirect github.com/yuin/goldmark-emoji v1.0.4 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect - golang.org/x/net v0.27.0 // indirect + golang.org/x/net v0.33.0 // indirect golang.org/x/sync v0.10.0 // indirect golang.org/x/sys v0.28.0 // indirect - golang.org/x/term v0.22.0 // indirect + golang.org/x/term v0.27.0 // indirect ) diff --git a/go.sum b/go.sum index 88954fb..57c8bbb 100644 --- a/go.sum +++ b/go.sum @@ -94,16 +94,16 @@ github.com/yuin/goldmark-emoji v1.0.4 h1:vCwMkPZSNefSUnOW2ZKRUjBSD5Ok3W78IXhGxxA github.com/yuin/goldmark-emoji v1.0.4/go.mod h1:tTkZEbwu5wkPmgTcitqddVxY9osFZiavD+r4AzQrh1U= golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY= golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= -golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= +golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= +golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= From 3dcc8b3f370ae3b632438c6aea764046dc65ca08 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 15 Jan 2025 05:06:10 +0000 Subject: [PATCH 111/198] chore(deps): bump github.com/charmbracelet/x/ansi (#801) Bumps [github.com/charmbracelet/x/ansi](https://github.com/charmbracelet/x) from 0.6.1-0.20250107110353-48b574af22a5 to 0.7.0. - [Release notes](https://github.com/charmbracelet/x/releases) - [Commits](https://github.com/charmbracelet/x/commits/ansi/v0.7.0) --- updated-dependencies: - dependency-name: github.com/charmbracelet/x/ansi dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4004221..eb17f5f 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/lipgloss v1.0.0 github.com/charmbracelet/log v0.4.0 - github.com/charmbracelet/x/ansi v0.6.1-0.20250107110353-48b574af22a5 + github.com/charmbracelet/x/ansi v0.7.0 github.com/charmbracelet/x/editor v0.1.0 github.com/charmbracelet/x/term v0.2.1 github.com/muesli/reflow v0.3.0 diff --git a/go.sum b/go.sum index 57c8bbb..7c0f230 100644 --- a/go.sum +++ b/go.sum @@ -30,8 +30,8 @@ github.com/charmbracelet/lipgloss v1.0.0 h1:O7VkGDvqEdGi93X+DeqsQ7PKHDgtQfF8j8/O github.com/charmbracelet/lipgloss v1.0.0/go.mod h1:U5fy9Z+C38obMs+T+tJqst9VGzlOYGj4ri9reL3qUlo= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= -github.com/charmbracelet/x/ansi v0.6.1-0.20250107110353-48b574af22a5 h1:TSjbA80sXnABV/Vxhnb67Ho7p8bEYqz6NIdhLAx+1yg= -github.com/charmbracelet/x/ansi v0.6.1-0.20250107110353-48b574af22a5/go.mod h1:KBUFw1la39nl0dLl10l5ORDAqGXaeurTQmwyyVKse/Q= +github.com/charmbracelet/x/ansi v0.7.0 h1:/QfFmiXOGGwN6fRbzvQaYp7fu1pkxpZ3qFBZWBsP404= +github.com/charmbracelet/x/ansi v0.7.0/go.mod h1:KBUFw1la39nl0dLl10l5ORDAqGXaeurTQmwyyVKse/Q= github.com/charmbracelet/x/editor v0.1.0 h1:p69/dpvlwRTs9uYiPeAWruwsHqTFzHhTvQOd/WVSX98= github.com/charmbracelet/x/editor v0.1.0/go.mod h1:oivrEbcP/AYt/Hpvk5pwDXXrQ933gQS6UzL6fxqAGSA= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q= From 65516a664c827c4731a9c84bcf68504691936505 Mon Sep 17 00:00:00 2001 From: ctn-malone <60197791+ctn-malone@users.noreply.github.com> Date: Tue, 21 Jan 2025 13:34:38 +0100 Subject: [PATCH 112/198] chore(nix): update src hash and nix version (#810) --- default.nix | 4 ++-- flake.lock | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/default.nix b/default.nix index f478b08..5c14976 100644 --- a/default.nix +++ b/default.nix @@ -2,11 +2,11 @@ pkgs.buildGoModule rec { pname = "gum"; - version = "0.14.0"; + version = "0.15.0"; src = ./.; - vendorHash = "sha256-UNBDVIz2VEizkhelCjadkzd2S2yTYXecTFUpCf+XtxY="; + vendorHash = "sha256-i/KBe41ufYA+tqnB5LCC1geIc2Jnh97JLXcXfBgxdM4="; ldflags = [ "-s" "-w" "-X=main.Version=${version}" ]; } diff --git a/flake.lock b/flake.lock index 7ceb95c..2537edd 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1715447595, - "narHash": "sha256-VsVAUQOj/cS1LCOmMjAGeRksXIAdPnFIjCQ0XLkCsT0=", + "lastModified": 1737062831, + "narHash": "sha256-Tbk1MZbtV2s5aG+iM99U8FqwxU/YNArMcWAv6clcsBc=", "owner": "nixos", "repo": "nixpkgs", - "rev": "062ca2a9370a27a35c524dc82d540e6e9824b652", + "rev": "5df43628fdf08d642be8ba5b3625a6c70731c19c", "type": "github" }, "original": { From 7e3216e2c8e10df991703bf4e05ffbceb9841a30 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 21 Jan 2025 19:33:52 -0300 Subject: [PATCH 113/198] fix(viewport): remove extra line in viewport help (#816) --- pager/pager.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pager/pager.go b/pager/pager.go index 2ee9b1e..42116bd 100644 --- a/pager/pager.go +++ b/pager/pager.go @@ -122,7 +122,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } func (m *model) helpView() string { - return "\n" + m.help.View(m.keymap) + return m.help.View(m.keymap) } func (m *model) processText(msg tea.WindowSizeMsg) { @@ -221,5 +221,5 @@ func (m model) View() string { return m.viewport.View() + "\n " + m.search.input.View() } - return m.viewport.View() + m.helpView() + return m.viewport.View() + "\n" + m.helpView() } From 05c4bb98687db82647419c849f2da626c19b1b0c Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 21 Jan 2025 19:37:50 -0300 Subject: [PATCH 114/198] fix: spin when not a tty (#813) * fix: spin when not a tty * fix: typo --- spin/command.go | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/spin/command.go b/spin/command.go index 20b31fa..02213f0 100644 --- a/spin/command.go +++ b/spin/command.go @@ -14,7 +14,8 @@ import ( // Run provides a shell script interface for the spinner bubble. // https://github.com/charmbracelet/bubbles/spinner func (o Options) Run() error { - isTTY := term.IsTerminal(os.Stdout.Fd()) + isOutTTY := term.IsTerminal(os.Stdout.Fd()) + isErrTTY := term.IsTerminal(os.Stderr.Fd()) s := spinner.New() s.Style = o.SpinnerStyle.ToLipgloss() @@ -24,25 +25,21 @@ func (o Options) Run() error { title: o.TitleStyle.ToLipgloss().Render(o.Title), command: o.Command, align: o.Align, - showStdout: (o.ShowOutput || o.ShowStdout) && isTTY, - showStderr: (o.ShowOutput || o.ShowStderr) && isTTY, + showStdout: (o.ShowOutput || o.ShowStdout) && isOutTTY, + showStderr: (o.ShowOutput || o.ShowStderr) && isErrTTY, showError: o.ShowError, - isTTY: isTTY, + isTTY: isErrTTY, } ctx, cancel := timeout.Context(o.Timeout) defer cancel() - opts := []tea.ProgramOption{ + tm, err := tea.NewProgram( + m, tea.WithOutput(os.Stderr), tea.WithContext(ctx), - } - - if !isTTY { - opts = append(opts, tea.WithInput(nil)) - } - - tm, err := tea.NewProgram(m, opts...).Run() + tea.WithInput(nil), + ).Run() if err != nil { return fmt.Errorf("unable to run action: %w", err) } @@ -55,7 +52,7 @@ func (o Options) Run() error { if o.ShowOutput { // BubbleTea writes the View() to stderr. // If the program is being piped then put the accumulated output in stdout. - if !isTTY { + if !isOutTTY { _, err := os.Stdout.WriteString(m.stdout) if err != nil { return fmt.Errorf("failed to write to stdout: %w", err) From 2da952756f2ecc7d2a09528fe9a863ac49c359dc Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 22 Jan 2025 11:17:56 -0300 Subject: [PATCH 115/198] fix(spin): clear title after finished (#815) closes #802 Signed-off-by: Carlos Alexandro Becker --- spin/spin.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spin/spin.go b/spin/spin.go index cb9a1aa..d675bab 100644 --- a/spin/spin.go +++ b/spin/spin.go @@ -103,10 +103,6 @@ func (m model) Init() tea.Cmd { } func (m model) View() string { - if !m.isTTY { - return m.title - } - var out string if m.showStderr { out += errbuf.String() @@ -115,10 +111,14 @@ func (m model) View() string { out += outbuf.String() } - if m.quitting && out != "" { + if m.quitting { return out } + if !m.isTTY { + return m.title + } + var header string if m.align == "left" { header = m.spinner.View() + " " + m.title From 2846d19b70b0141cdb18e4611c4859f11971808a Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 22 Jan 2025 11:18:53 -0300 Subject: [PATCH 116/198] Revert "feat(table): set --print if stdout is not a terminal (#762)" (#811) This reverts commit 05614c8196b9289cf42c15feb0759a344ed4825e. --- table/command.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/table/command.go b/table/command.go index 3cdb81c..ae52bbf 100644 --- a/table/command.go +++ b/table/command.go @@ -13,7 +13,6 @@ import ( "github.com/charmbracelet/gum/style" "github.com/charmbracelet/lipgloss" ltable "github.com/charmbracelet/lipgloss/table" - "github.com/charmbracelet/x/term" "golang.org/x/text/encoding" "golang.org/x/text/encoding/unicode" "golang.org/x/text/transform" @@ -110,7 +109,7 @@ func (o Options) Run() error { rows = append(rows, table.Row(data[row])) } - if o.Print || !term.IsTerminal(os.Stdout.Fd()) { + if o.Print { table := ltable.New(). Headers(columnNames...). Rows(data...). From 30bc180679cf3c9139783af7c95eab953af60fb3 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 22 Jan 2025 11:19:10 -0300 Subject: [PATCH 117/198] fix(confirm): do not print 'not confirmed' on exit 1 (#814) closes #809 --- confirm/command.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/confirm/command.go b/confirm/command.go index 103fbad..ed5cf6e 100644 --- a/confirm/command.go +++ b/confirm/command.go @@ -1,18 +1,16 @@ package confirm import ( - "errors" "fmt" "os" "github.com/charmbracelet/bubbles/help" tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/gum/internal/exit" "github.com/charmbracelet/gum/internal/stdin" "github.com/charmbracelet/gum/internal/timeout" ) -var errNotConfirmed = errors.New("not confirmed") - // Run provides a shell script interface for prompting a user to confirm an // action with an affirmative or negative answer. func (o Options) Run() error { @@ -22,7 +20,7 @@ func (o Options) Run() error { case "yes", "y": return nil default: - return errNotConfirmed + return exit.ErrExit(1) } } @@ -65,5 +63,5 @@ func (o Options) Run() error { return nil } - return errNotConfirmed + return exit.ErrExit(1) } From c11af42c1b438bac62c7ece0271f450770da6e07 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 22 Jan 2025 12:51:04 -0300 Subject: [PATCH 118/198] fix(write): ctrl+j not making new line (#819) --- write/command.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/write/command.go b/write/command.go index 548cd95..adc3c69 100644 --- a/write/command.go +++ b/write/command.go @@ -60,6 +60,8 @@ func (o Options) Run() error { keymap: defaultKeymap(), } + m.textarea.KeyMap.InsertNewline = m.keymap.InsertNewline + ctx, cancel := timeout.Context(o.Timeout) defer cancel() From 37456557c454a97a66454597c26d1dc2156a9f15 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 22 Jan 2025 12:51:18 -0300 Subject: [PATCH 119/198] fix(filter): wrong highlight when option has grapheme clusters (#799) --- filter/filter.go | 51 ++++++++++++++++++++++++++----------------- filter/filter_test.go | 18 +++++++++++++++ go.mod | 4 ++-- go.sum | 4 ++-- 4 files changed, 53 insertions(+), 24 deletions(-) diff --git a/filter/filter.go b/filter/filter.go index 0c72023..d321bcb 100644 --- a/filter/filter.go +++ b/filter/filter.go @@ -19,7 +19,7 @@ import ( "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" - "github.com/charmbracelet/x/ansi" + "github.com/rivo/uniseg" "github.com/sahilm/fuzzy" ) @@ -211,28 +211,16 @@ func (m model) View() string { continue } - var buf strings.Builder - lastIdx := 0 - - // Use ansi.Truncate and ansi.TruncateLeft and ansi.StringWidth to - // style match.MatchedIndexes without losing the original option style: + var ranges []lipgloss.Range for _, rng := range matchedRanges(match.MatchedIndexes) { - // fmt.Print("here ", lastIdx, rng, " - ", match.Str[rng[0]:rng[1]+1], "\r\n") - // Add the text before this match - if rng[0] > lastIdx { - buf.WriteString(ansi.Cut(styledOption, lastIdx, rng[0])) - } - - // Add the matched character with highlight - buf.WriteString(m.matchStyle.Render(ansi.Cut(match.Str, rng[0], rng[1]+1))) - lastIdx = rng[1] + 1 + // ansi.Cut is grapheme and ansi sequence aware, we match against a ansi.Stripped string, but we might still have graphemes. + // all that to say that rng is byte positions, but we need to pass it down to ansi.Cut as char positions. + // so we need to adjust it here: + start, stop := bytePosToVisibleCharPos(match.Str, rng) + ranges = append(ranges, lipgloss.NewRange(start, stop+1, m.matchStyle)) } - // Add any remaining text after the last match - buf.WriteString(ansi.TruncateLeft(styledOption, lastIdx, "")) - - // Flush text buffer. - s.WriteString(lineTextStyle.Render(buf.String())) + s.WriteString(lineTextStyle.Render(lipgloss.StyleRanges(styledOption, ranges...))) // We have finished displaying the match with all of it's matched // characters highlighted and the rest filled in. @@ -540,3 +528,26 @@ func matchedRanges(in []int) [][2]int { out = append(out, current) return out } + +func bytePosToVisibleCharPos(str string, rng [2]int) (int, int) { + bytePos, byteStart, byteStop := 0, rng[0], rng[1] + pos, start, stop := 0, 0, 0 + gr := uniseg.NewGraphemes(str) + for byteStart > bytePos { + if !gr.Next() { + break + } + bytePos += len(gr.Str()) + pos += max(1, gr.Width()) + } + start = pos + for byteStop > bytePos { + if !gr.Next() { + break + } + bytePos += len(gr.Str()) + pos += max(1, gr.Width()) + } + stop = pos + return start, stop +} diff --git a/filter/filter_test.go b/filter/filter_test.go index 56e7590..5840002 100644 --- a/filter/filter_test.go +++ b/filter/filter_test.go @@ -3,6 +3,8 @@ package filter import ( "reflect" "testing" + + "github.com/charmbracelet/x/ansi" ) func TestMatchedRanges(t *testing.T) { @@ -39,3 +41,19 @@ func TestMatchedRanges(t *testing.T) { }) } } + +func TestByteToChar(t *testing.T) { + stStr := "\x1b[90m\ue615\x1b[39m \x1b[3m\x1b[32mDow\x1b[0m\x1b[90m\x1b[39m\x1b[3wnloads" + str := " Downloads" + rng := [2]int{4, 7} + expect := "Dow" + + if got := str[rng[0]:rng[1]]; got != expect { + t.Errorf("expected %q, got %q", expect, got) + } + + start, stop := bytePosToVisibleCharPos(str, rng) + if got := ansi.Strip(ansi.Cut(stStr, start, stop)); got != expect { + t.Errorf("expected %+q, got %+q", expect, got) + } +} diff --git a/go.mod b/go.mod index eb17f5f..5f13653 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/charmbracelet/bubbles v0.20.0 github.com/charmbracelet/bubbletea v1.2.5-0.20241207142916-e0515bc22ad1 github.com/charmbracelet/glamour v0.8.0 - github.com/charmbracelet/lipgloss v1.0.0 + github.com/charmbracelet/lipgloss v1.0.1-0.20250110214317-ecc1bd014d51 github.com/charmbracelet/log v0.4.0 github.com/charmbracelet/x/ansi v0.7.0 github.com/charmbracelet/x/editor v0.1.0 @@ -17,6 +17,7 @@ require ( github.com/muesli/reflow v0.3.0 github.com/muesli/roff v0.1.0 github.com/muesli/termenv v0.15.3-0.20241211131612-0d230cb6eb15 + github.com/rivo/uniseg v0.4.7 github.com/sahilm/fuzzy v0.1.1 golang.org/x/text v0.21.0 ) @@ -39,7 +40,6 @@ require ( github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect github.com/muesli/cancelreader v0.2.2 // indirect github.com/muesli/mango v0.2.0 // indirect - github.com/rivo/uniseg v0.4.7 // indirect github.com/yuin/goldmark v1.7.4 // indirect github.com/yuin/goldmark-emoji v1.0.4 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect diff --git a/go.sum b/go.sum index 7c0f230..776f9f4 100644 --- a/go.sum +++ b/go.sum @@ -26,8 +26,8 @@ github.com/charmbracelet/bubbletea v1.2.5-0.20241207142916-e0515bc22ad1 h1:osd3d github.com/charmbracelet/bubbletea v1.2.5-0.20241207142916-e0515bc22ad1/go.mod h1:Hbk5+oE4a7cDyjfdPi4sHZ42aGTMYcmHnVDhsRswn7A= github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= -github.com/charmbracelet/lipgloss v1.0.0 h1:O7VkGDvqEdGi93X+DeqsQ7PKHDgtQfF8j8/O2qFMQNg= -github.com/charmbracelet/lipgloss v1.0.0/go.mod h1:U5fy9Z+C38obMs+T+tJqst9VGzlOYGj4ri9reL3qUlo= +github.com/charmbracelet/lipgloss v1.0.1-0.20250110214317-ecc1bd014d51 h1:f+0mEkhorXNiBaHb4V9wyd364OH/aF7md7ZngkS+1gU= +github.com/charmbracelet/lipgloss v1.0.1-0.20250110214317-ecc1bd014d51/go.mod h1:QRGthpgH59/perglqXZC8xPHqDGZ9BB45ChJCFEWEMI= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= github.com/charmbracelet/x/ansi v0.7.0 h1:/QfFmiXOGGwN6fRbzvQaYp7fu1pkxpZ3qFBZWBsP404= From e7c916cff66028ea32e608bc3802bb7aa963e522 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Jan 2025 04:28:08 +0000 Subject: [PATCH 120/198] chore(deps): bump github.com/charmbracelet/x/ansi from 0.7.0 to 0.8.0 (#826) Bumps [github.com/charmbracelet/x/ansi](https://github.com/charmbracelet/x) from 0.7.0 to 0.8.0. - [Release notes](https://github.com/charmbracelet/x/releases) - [Commits](https://github.com/charmbracelet/x/compare/ansi/v0.7.0...ansi/v0.8.0) --- updated-dependencies: - dependency-name: github.com/charmbracelet/x/ansi dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5f13653..db48099 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/lipgloss v1.0.1-0.20250110214317-ecc1bd014d51 github.com/charmbracelet/log v0.4.0 - github.com/charmbracelet/x/ansi v0.7.0 + github.com/charmbracelet/x/ansi v0.8.0 github.com/charmbracelet/x/editor v0.1.0 github.com/charmbracelet/x/term v0.2.1 github.com/muesli/reflow v0.3.0 diff --git a/go.sum b/go.sum index 776f9f4..7b3c806 100644 --- a/go.sum +++ b/go.sum @@ -30,8 +30,8 @@ github.com/charmbracelet/lipgloss v1.0.1-0.20250110214317-ecc1bd014d51 h1:f+0mEk github.com/charmbracelet/lipgloss v1.0.1-0.20250110214317-ecc1bd014d51/go.mod h1:QRGthpgH59/perglqXZC8xPHqDGZ9BB45ChJCFEWEMI= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= -github.com/charmbracelet/x/ansi v0.7.0 h1:/QfFmiXOGGwN6fRbzvQaYp7fu1pkxpZ3qFBZWBsP404= -github.com/charmbracelet/x/ansi v0.7.0/go.mod h1:KBUFw1la39nl0dLl10l5ORDAqGXaeurTQmwyyVKse/Q= +github.com/charmbracelet/x/ansi v0.8.0 h1:9GTq3xq9caJW8ZrBTe0LIe2fvfLR/bYXKTx2llXn7xE= +github.com/charmbracelet/x/ansi v0.8.0/go.mod h1:wdYl/ONOLHLIVmQaxbIYEC/cRKOQyjTkowiI4blgS9Q= github.com/charmbracelet/x/editor v0.1.0 h1:p69/dpvlwRTs9uYiPeAWruwsHqTFzHhTvQOd/WVSX98= github.com/charmbracelet/x/editor v0.1.0/go.mod h1:oivrEbcP/AYt/Hpvk5pwDXXrQ933gQS6UzL6fxqAGSA= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q= From d1fc05155cb846583260d8ea6be4ef1b2a03dbc7 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 28 Jan 2025 11:50:36 -0300 Subject: [PATCH 121/198] fix(pager): memory/cpu usage when using soft-wrap (#827) easily reproducible, especially with something like ```sh PAGER="gum pager" man ls ``` Problems here were: - reflow's truncate is not very efficient - useless calls to truncate - bad strings.Replace calls (not necessary, and wouldn't work if text has ansi sequences) --- go.mod | 2 +- pager/pager.go | 24 ++++++++++++++---------- pager/search.go | 18 +++++++++++------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/go.mod b/go.mod index db48099..49a2839 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,6 @@ require ( github.com/charmbracelet/x/ansi v0.8.0 github.com/charmbracelet/x/editor v0.1.0 github.com/charmbracelet/x/term v0.2.1 - github.com/muesli/reflow v0.3.0 github.com/muesli/roff v0.1.0 github.com/muesli/termenv v0.15.3-0.20241211131612-0d230cb6eb15 github.com/rivo/uniseg v0.4.7 @@ -40,6 +39,7 @@ require ( github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect github.com/muesli/cancelreader v0.2.2 // indirect github.com/muesli/mango v0.2.0 // indirect + github.com/muesli/reflow v0.3.0 // indirect github.com/yuin/goldmark v1.7.4 // indirect github.com/yuin/goldmark-emoji v1.0.4 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect diff --git a/pager/pager.go b/pager/pager.go index 42116bd..6b38403 100644 --- a/pager/pager.go +++ b/pager/pager.go @@ -13,7 +13,7 @@ import ( "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" - "github.com/muesli/reflow/truncate" + "github.com/charmbracelet/x/ansi" ) type keymap struct { @@ -146,17 +146,21 @@ func (m *model) processText(msg tea.WindowSizeMsg) { if m.showLineNumbers { text.WriteString(m.lineNumberStyle.Render(fmt.Sprintf("%4d │ ", i+1))) } - for m.softWrap && lipgloss.Width(line) > m.maxWidth { - truncatedLine := truncate.String(line, uint(m.maxWidth)) //nolint: gosec - text.WriteString(textStyle.Render(truncatedLine)) - text.WriteString("\n") - if m.showLineNumbers { - text.WriteString(m.lineNumberStyle.Render(" │ ")) + idx := 0 + if w := ansi.StringWidth(line); m.softWrap && w > m.maxWidth { + for w > idx { + if m.showLineNumbers && idx != 0 { + text.WriteString(m.lineNumberStyle.Render(" │ ")) + } + truncatedLine := ansi.Cut(line, idx, m.maxWidth+idx) + idx += m.maxWidth + text.WriteString(textStyle.Render(truncatedLine)) + text.WriteString("\n") } - line = strings.Replace(line, truncatedLine, "", 1) + } else { + text.WriteString(textStyle.Render(line)) //nolint: gosec + text.WriteString("\n") } - text.WriteString(textStyle.Render(truncate.String(line, uint(m.maxWidth)))) //nolint: gosec - text.WriteString("\n") } diffHeight := m.viewport.Height - lipgloss.Height(text.String()) diff --git a/pager/search.go b/pager/search.go index e32260d..be59a53 100644 --- a/pager/search.go +++ b/pager/search.go @@ -8,7 +8,7 @@ import ( "github.com/charmbracelet/bubbles/textinput" "github.com/charmbracelet/gum/internal/utils" "github.com/charmbracelet/lipgloss" - "github.com/muesli/reflow/truncate" + "github.com/charmbracelet/x/ansi" ) type search struct { @@ -150,14 +150,18 @@ func (s *search) PrevMatch(m *model) { func softWrapEm(str string, maxWidth int, softWrap bool) string { var text strings.Builder for _, line := range strings.Split(str, "\n") { - for softWrap && lipgloss.Width(line) > maxWidth { - truncatedLine := truncate.String(line, uint(maxWidth)) //nolint: gosec - text.WriteString(truncatedLine) + idx := 0 + if w := ansi.StringWidth(line); softWrap && w > maxWidth { + for w > idx { + truncatedLine := ansi.Cut(line, idx, maxWidth+idx) + idx += maxWidth + text.WriteString(truncatedLine) + text.WriteString("\n") + } + } else { + text.WriteString(line) //nolint: gosec text.WriteString("\n") - line = strings.Replace(line, truncatedLine, "", 1) } - text.WriteString(truncate.String(line, uint(maxWidth))) //nolint: gosec - text.WriteString("\n") } return text.String() From 928ba9ace0d6b28edcc5ebcb6eb10add50ffffc1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 30 Jan 2025 04:51:54 +0000 Subject: [PATCH 122/198] chore(deps): bump github.com/alecthomas/kong from 1.6.1 to 1.7.0 (#832) Bumps [github.com/alecthomas/kong](https://github.com/alecthomas/kong) from 1.6.1 to 1.7.0. - [Release notes](https://github.com/alecthomas/kong/releases) - [Commits](https://github.com/alecthomas/kong/compare/v1.6.1...v1.7.0) --- updated-dependencies: - dependency-name: github.com/alecthomas/kong dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 49a2839..44f29b1 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.23.0 require ( github.com/Masterminds/semver/v3 v3.3.1 - github.com/alecthomas/kong v1.6.1 + github.com/alecthomas/kong v1.7.0 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 github.com/charmbracelet/bubbletea v1.2.5-0.20241207142916-e0515bc22ad1 diff --git a/go.sum b/go.sum index 7b3c806..5114e48 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8v github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E= github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I= -github.com/alecthomas/kong v1.6.1 h1:/7bVimARU3uxPD0hbryPE8qWrS3Oz3kPQoxA/H2NKG8= -github.com/alecthomas/kong v1.6.1/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= +github.com/alecthomas/kong v1.7.0 h1:MnT8+5JxFDCvISeI6vgd/mFbAJwueJ/pqQNzZMsiqZE= +github.com/alecthomas/kong v1.7.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= github.com/alecthomas/mango-kong v0.1.0 h1:iFVfP1k1K4qpml3JUQmD5I8MCQYfIvsD9mRdrw7jJC4= github.com/alecthomas/mango-kong v0.1.0/go.mod h1:t+TYVdsONUolf/BwVcm+15eqcdAj15h4Qe9MMFAwwT4= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= From bb9fee73316c3c144f71fc6ca1bd61aef8c9269d Mon Sep 17 00:00:00 2001 From: BitBoss Date: Fri, 31 Jan 2025 09:37:22 -0800 Subject: [PATCH 123/198] docs: update FreeBSD installation instructions. (#824) Co-authored-by: Dave Turner --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index a538089..04b14af 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,19 @@ sudo zypper install gum +
+FreeBSD + +```bash +# packages +sudo pkg install gum + +# ports +cd /usr/ports/devel/gum && sudo make install clean +``` + +
+ Or download it: - [Packages][releases] are available in Debian, RPM, and Alpine formats From 9705aa338448bb7b2b797f09866b7e14247bf0ea Mon Sep 17 00:00:00 2001 From: Raphael Amorim Date: Mon, 3 Feb 2025 14:43:46 -0300 Subject: [PATCH 124/198] fix: generated completion invalid for fish shell (#837) --- filter/options.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filter/options.go b/filter/options.go index 07c50ce..e63644b 100644 --- a/filter/options.go +++ b/filter/options.go @@ -15,7 +15,7 @@ type Options struct { Limit int `help:"Maximum number of options to pick" default:"1" group:"Selection"` NoLimit bool `help:"Pick unlimited number of options (ignores limit)" group:"Selection"` SelectIfOne bool `help:"Select the given option if there is only one" group:"Selection"` - Selected []string `help:"Options that should start as selected (selects all if given '*')" default:"" env:"GUM_FILTER_SELECTED"` + Selected []string `help:"Options that should start as selected (selects all if given *)" default:"" env:"GUM_FILTER_SELECTED"` ShowHelp bool `help:"Show help keybinds" default:"true" negatable:"" env:"GUM_FILTER_SHOW_HELP"` Strict bool `help:"Only returns if anything matched. Otherwise return Filter" negatable:"" default:"true" group:"Selection"` SelectedPrefix string `help:"Character to indicate selected items (hidden if limit is 1)" default:" ◉ " env:"GUM_FILTER_SELECTED_PREFIX"` From bb098b2662682141474ca8398197e8a2e94cfe6a Mon Sep 17 00:00:00 2001 From: Raphael Amorim Date: Mon, 3 Feb 2025 14:55:05 -0300 Subject: [PATCH 125/198] fix: generated completion invalid for fish shell (choose/options) (#838) --- choose/options.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/choose/options.go b/choose/options.go index e5ea6b2..f956eb0 100644 --- a/choose/options.go +++ b/choose/options.go @@ -20,7 +20,7 @@ type Options struct { CursorPrefix string `help:"Prefix to show on the cursor item (hidden if limit is 1)" default:"• " env:"GUM_CHOOSE_CURSOR_PREFIX"` SelectedPrefix string `help:"Prefix to show on selected items (hidden if limit is 1)" default:"✓ " env:"GUM_CHOOSE_SELECTED_PREFIX"` UnselectedPrefix string `help:"Prefix to show on unselected items (hidden if limit is 1)" default:"• " env:"GUM_CHOOSE_UNSELECTED_PREFIX"` - Selected []string `help:"Options that should start as selected (selects all if given '*')" default:"" env:"GUM_CHOOSE_SELECTED"` + Selected []string `help:"Options that should start as selected (selects all if given *)" default:"" env:"GUM_CHOOSE_SELECTED"` SelectIfOne bool `help:"Select the given option if there is only one" group:"Selection"` InputDelimiter string `help:"Option delimiter when reading from STDIN" default:"\n" env:"GUM_CHOOSE_INPUT_DELIMITER"` OutputDelimiter string `help:"Option delimiter when writing to STDOUT" default:"\n" env:"GUM_CHOOSE_OUTPUT_DELIMITER"` From 984c84fbd02e06589928bfa66304f3db1dc76605 Mon Sep 17 00:00:00 2001 From: Raphael Amorim Date: Tue, 4 Feb 2025 11:54:06 -0300 Subject: [PATCH 126/198] feat: show indicator on help keybindings (opt-in) (#839) * feat: show indicator on help keybindings (opt-in) * format code --- table/command.go | 9 +++++---- table/options.go | 1 + table/table.go | 25 ++++++++++++++++++------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/table/command.go b/table/command.go index ae52bbf..6b92e24 100644 --- a/table/command.go +++ b/table/command.go @@ -142,10 +142,11 @@ func (o Options) Run() error { defer cancel() m := model{ - table: table, - showHelp: o.ShowHelp, - help: help.New(), - keymap: defaultKeymap(), + table: table, + showHelp: o.ShowHelp, + hideIndicator: o.HideIndicator, + help: help.New(), + keymap: defaultKeymap(), } tm, err := tea.NewProgram( m, diff --git a/table/options.go b/table/options.go index 5949c92..25b8e4d 100644 --- a/table/options.go +++ b/table/options.go @@ -16,6 +16,7 @@ type Options struct { File string `short:"f" help:"file path" default:""` Border string `short:"b" help:"border style" default:"rounded" enum:"rounded,thick,normal,hidden,double,none"` ShowHelp bool `help:"Show help keybinds" default:"true" negatable:"" env:"GUM_TABLE_SHOW_HELP"` + HideIndicator bool `help:"Hide indicator on help keybinds" default:"false" negatable:"" env:"GUM_TABLE_HIDE_INDICATOR"` LazyQuotes bool `help:"If LazyQuotes is true, a quote may appear in an unquoted field and a non-doubled quote may appear in a quoted field" default:"false" env:"GUM_TABLE_LAZY_QUOTES"` FieldsPerRecord int `help:"Sets the number of expected fields per record" default:"0" env:"GUM_TABLE_FIELDS_PER_RECORD"` diff --git a/table/table.go b/table/table.go index cbbb213..73fc98f 100644 --- a/table/table.go +++ b/table/table.go @@ -15,6 +15,8 @@ package table import ( + "fmt" + "github.com/charmbracelet/bubbles/help" "github.com/charmbracelet/bubbles/key" "github.com/charmbracelet/bubbles/table" @@ -62,16 +64,25 @@ func defaultKeymap() keymap { } type model struct { - table table.Model - selected table.Row - quitting bool - showHelp bool - help help.Model - keymap keymap + table table.Model + selected table.Row + quitting bool + showHelp bool + hideIndicator bool + help help.Model + keymap keymap } func (m model) Init() tea.Cmd { return nil } +func (m model) inidicatorView() string { + if m.hideIndicator { + return "" + } + + return m.help.Styles.FullDesc.Render(fmt.Sprintf("%d/%d%s", m.table.Cursor()+1, len(m.table.Rows()), m.help.ShortSeparator)) +} + func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { var cmd tea.Cmd @@ -102,7 +113,7 @@ func (m model) View() string { } s := m.table.View() if m.showHelp { - s += "\n" + m.help.View(m.keymap) + s += "\n" + m.inidicatorView() + m.help.View(m.keymap) } return s } From 5660060c40dbad952e9c5688875a95f8a8159d86 Mon Sep 17 00:00:00 2001 From: Raphael Amorim Date: Tue, 4 Feb 2025 12:35:00 -0300 Subject: [PATCH 127/198] rename to count instead (#840) --- table/command.go | 10 +++++----- table/options.go | 2 +- table/table.go | 20 ++++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/table/command.go b/table/command.go index 6b92e24..4ee0fb9 100644 --- a/table/command.go +++ b/table/command.go @@ -142,11 +142,11 @@ func (o Options) Run() error { defer cancel() m := model{ - table: table, - showHelp: o.ShowHelp, - hideIndicator: o.HideIndicator, - help: help.New(), - keymap: defaultKeymap(), + table: table, + showHelp: o.ShowHelp, + hideCount: o.HideCount, + help: help.New(), + keymap: defaultKeymap(), } tm, err := tea.NewProgram( m, diff --git a/table/options.go b/table/options.go index 25b8e4d..58efaa4 100644 --- a/table/options.go +++ b/table/options.go @@ -16,7 +16,7 @@ type Options struct { File string `short:"f" help:"file path" default:""` Border string `short:"b" help:"border style" default:"rounded" enum:"rounded,thick,normal,hidden,double,none"` ShowHelp bool `help:"Show help keybinds" default:"true" negatable:"" env:"GUM_TABLE_SHOW_HELP"` - HideIndicator bool `help:"Hide indicator on help keybinds" default:"false" negatable:"" env:"GUM_TABLE_HIDE_INDICATOR"` + HideCount bool `help:"Hide item count on help keybinds" default:"false" negatable:"" env:"GUM_TABLE_HIDE_COUNT"` LazyQuotes bool `help:"If LazyQuotes is true, a quote may appear in an unquoted field and a non-doubled quote may appear in a quoted field" default:"false" env:"GUM_TABLE_LAZY_QUOTES"` FieldsPerRecord int `help:"Sets the number of expected fields per record" default:"0" env:"GUM_TABLE_FIELDS_PER_RECORD"` diff --git a/table/table.go b/table/table.go index 73fc98f..3574e48 100644 --- a/table/table.go +++ b/table/table.go @@ -64,19 +64,19 @@ func defaultKeymap() keymap { } type model struct { - table table.Model - selected table.Row - quitting bool - showHelp bool - hideIndicator bool - help help.Model - keymap keymap + table table.Model + selected table.Row + quitting bool + showHelp bool + hideCount bool + help help.Model + keymap keymap } func (m model) Init() tea.Cmd { return nil } -func (m model) inidicatorView() string { - if m.hideIndicator { +func (m model) countView() string { + if m.hideCount { return "" } @@ -113,7 +113,7 @@ func (m model) View() string { } s := m.table.View() if m.showHelp { - s += "\n" + m.inidicatorView() + m.help.View(m.keymap) + s += "\n" + m.countView() + m.help.View(m.keymap) } return s } From ce6bb49ce06d1f0b1efc8e0e86d6b7398cf51955 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 4 Feb 2025 16:10:46 -0300 Subject: [PATCH 128/198] chore(deps): use latest stable bubbletea Signed-off-by: Carlos Alexandro Becker --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 44f29b1..f519514 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/alecthomas/kong v1.7.0 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 - github.com/charmbracelet/bubbletea v1.2.5-0.20241207142916-e0515bc22ad1 + github.com/charmbracelet/bubbletea v1.3.0 github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/lipgloss v1.0.1-0.20250110214317-ecc1bd014d51 github.com/charmbracelet/log v0.4.0 @@ -45,6 +45,6 @@ require ( golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/net v0.33.0 // indirect golang.org/x/sync v0.10.0 // indirect - golang.org/x/sys v0.28.0 // indirect + golang.org/x/sys v0.29.0 // indirect golang.org/x/term v0.27.0 // indirect ) diff --git a/go.sum b/go.sum index 5114e48..581cde9 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE= github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU= -github.com/charmbracelet/bubbletea v1.2.5-0.20241207142916-e0515bc22ad1 h1:osd3dk14DEriOrqJBWzeDE9eN2Yd00BkKzFAiLXxkS8= -github.com/charmbracelet/bubbletea v1.2.5-0.20241207142916-e0515bc22ad1/go.mod h1:Hbk5+oE4a7cDyjfdPi4sHZ42aGTMYcmHnVDhsRswn7A= +github.com/charmbracelet/bubbletea v1.3.0 h1:fPMyirm0u3Fou+flch7hlJN9krlnVURrkUVDwqXjoAc= +github.com/charmbracelet/bubbletea v1.3.0/go.mod h1:eTaHfqbIwvBhFQM/nlT1NsGc4kp8jhF8LfUK67XiTDM= github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= github.com/charmbracelet/lipgloss v1.0.1-0.20250110214317-ecc1bd014d51 h1:f+0mEkhorXNiBaHb4V9wyd364OH/aF7md7ZngkS+1gU= @@ -100,8 +100,8 @@ golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= +golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= From d795b8ab2ffb048f281d0af901d119ff00ebba59 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 4 Feb 2025 16:38:09 -0300 Subject: [PATCH 129/198] fix(table): padding on item indicator (#841) --- table/table.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/table/table.go b/table/table.go index 3574e48..9c6ed72 100644 --- a/table/table.go +++ b/table/table.go @@ -16,6 +16,7 @@ package table import ( "fmt" + "strconv" "github.com/charmbracelet/bubbles/help" "github.com/charmbracelet/bubbles/key" @@ -80,7 +81,13 @@ func (m model) countView() string { return "" } - return m.help.Styles.FullDesc.Render(fmt.Sprintf("%d/%d%s", m.table.Cursor()+1, len(m.table.Rows()), m.help.ShortSeparator)) + padding := strconv.Itoa(numLen(len(m.table.Rows()))) + return m.help.Styles.FullDesc.Render(fmt.Sprintf( + "%"+padding+"d/%d%s", + m.table.Cursor()+1, + len(m.table.Rows()), + m.help.ShortSeparator, + )) } func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { @@ -117,3 +124,15 @@ func (m model) View() string { } return s } + +func numLen(i int) int { + if i == 0 { + return 1 + } + count := 0 + for i != 0 { + i /= 10 + count++ + } + return count +} From 9a387e4079eb117dbd079f7a919ec1b1b99118b1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 5 Feb 2025 04:40:26 +0000 Subject: [PATCH 130/198] chore(deps): bump golang.org/x/text from 0.21.0 to 0.22.0 (#842) Bumps [golang.org/x/text](https://github.com/golang/text) from 0.21.0 to 0.22.0. - [Release notes](https://github.com/golang/text/releases) - [Commits](https://github.com/golang/text/compare/v0.21.0...v0.22.0) --- updated-dependencies: - dependency-name: golang.org/x/text dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index f519514..04eedab 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/muesli/termenv v0.15.3-0.20241211131612-0d230cb6eb15 github.com/rivo/uniseg v0.4.7 github.com/sahilm/fuzzy v0.1.1 - golang.org/x/text v0.21.0 + golang.org/x/text v0.22.0 ) require ( @@ -44,7 +44,7 @@ require ( github.com/yuin/goldmark-emoji v1.0.4 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/net v0.33.0 // indirect - golang.org/x/sync v0.10.0 // indirect + golang.org/x/sync v0.11.0 // indirect golang.org/x/sys v0.29.0 // indirect golang.org/x/term v0.27.0 // indirect ) diff --git a/go.sum b/go.sum index 581cde9..2dd41cd 100644 --- a/go.sum +++ b/go.sum @@ -96,15 +96,15 @@ golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0J golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= -golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= -golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= +golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= -golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= -golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= +golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= +golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 7b9d51d462f289e8fdfd1d5449344cab9ad01f88 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 04:43:23 +0000 Subject: [PATCH 131/198] chore(deps): bump github.com/alecthomas/kong from 1.7.0 to 1.8.0 (#849) Bumps [github.com/alecthomas/kong](https://github.com/alecthomas/kong) from 1.7.0 to 1.8.0. - [Release notes](https://github.com/alecthomas/kong/releases) - [Commits](https://github.com/alecthomas/kong/compare/v1.7.0...v1.8.0) --- updated-dependencies: - dependency-name: github.com/alecthomas/kong dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 04eedab..bf79b34 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.23.0 require ( github.com/Masterminds/semver/v3 v3.3.1 - github.com/alecthomas/kong v1.7.0 + github.com/alecthomas/kong v1.8.0 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 github.com/charmbracelet/bubbletea v1.3.0 diff --git a/go.sum b/go.sum index 2dd41cd..f596c8a 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8v github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E= github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I= -github.com/alecthomas/kong v1.7.0 h1:MnT8+5JxFDCvISeI6vgd/mFbAJwueJ/pqQNzZMsiqZE= -github.com/alecthomas/kong v1.7.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= +github.com/alecthomas/kong v1.8.0 h1:LEDIdSYrHU+4oTF2BL0NAfw++wH6lg/LzAJodTkLikM= +github.com/alecthomas/kong v1.8.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= github.com/alecthomas/mango-kong v0.1.0 h1:iFVfP1k1K4qpml3JUQmD5I8MCQYfIvsD9mRdrw7jJC4= github.com/alecthomas/mango-kong v0.1.0/go.mod h1:t+TYVdsONUolf/BwVcm+15eqcdAj15h4Qe9MMFAwwT4= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= From a30c8bdf3195cc6faee943cf560f0cf2a65952d9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Feb 2025 04:22:17 +0000 Subject: [PATCH 132/198] chore(deps): bump github.com/charmbracelet/bubbletea from 1.3.0 to 1.3.2 (#851) Bumps [github.com/charmbracelet/bubbletea](https://github.com/charmbracelet/bubbletea) from 1.3.0 to 1.3.2. - [Release notes](https://github.com/charmbracelet/bubbletea/releases) - [Changelog](https://github.com/charmbracelet/bubbletea/blob/main/.goreleaser.yml) - [Commits](https://github.com/charmbracelet/bubbletea/compare/v1.3.0...v1.3.2) --- updated-dependencies: - dependency-name: github.com/charmbracelet/bubbletea dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index bf79b34..19f994a 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/alecthomas/kong v1.8.0 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 - github.com/charmbracelet/bubbletea v1.3.0 + github.com/charmbracelet/bubbletea v1.3.2 github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/lipgloss v1.0.1-0.20250110214317-ecc1bd014d51 github.com/charmbracelet/log v0.4.0 @@ -45,6 +45,6 @@ require ( golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/net v0.33.0 // indirect golang.org/x/sync v0.11.0 // indirect - golang.org/x/sys v0.29.0 // indirect + golang.org/x/sys v0.30.0 // indirect golang.org/x/term v0.27.0 // indirect ) diff --git a/go.sum b/go.sum index f596c8a..a880e19 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE= github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU= -github.com/charmbracelet/bubbletea v1.3.0 h1:fPMyirm0u3Fou+flch7hlJN9krlnVURrkUVDwqXjoAc= -github.com/charmbracelet/bubbletea v1.3.0/go.mod h1:eTaHfqbIwvBhFQM/nlT1NsGc4kp8jhF8LfUK67XiTDM= +github.com/charmbracelet/bubbletea v1.3.2 h1:nc+gDivH0P8ii8CUcf3zCN/PiUz7LKbp3Iz+vYPScNY= +github.com/charmbracelet/bubbletea v1.3.2/go.mod h1:dtcUCyCGEX3g9tosuYiut3MXgY/Jsv9nKVdibKKRRXo= github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= github.com/charmbracelet/lipgloss v1.0.1-0.20250110214317-ecc1bd014d51 h1:f+0mEkhorXNiBaHb4V9wyd364OH/aF7md7ZngkS+1gU= @@ -100,8 +100,8 @@ golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= -golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= From 93f6857e3dc06e45f3fb2874ea3f798ae342068b Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Tue, 11 Feb 2025 11:51:38 -0800 Subject: [PATCH 133/198] fix(spin): preserve color output when `--show-output` is given (#850) --- go.mod | 5 ++++ go.sum | 10 +++++++ spin/command.go | 29 ++++++++++++-------- spin/pty.go | 22 ++++++++++++++++ spin/spin.go | 70 ++++++++++++++++++++++++++++++++++++++++--------- 5 files changed, 113 insertions(+), 23 deletions(-) create mode 100644 spin/pty.go diff --git a/go.mod b/go.mod index 19f994a..3e71643 100644 --- a/go.mod +++ b/go.mod @@ -14,6 +14,7 @@ require ( github.com/charmbracelet/x/ansi v0.8.0 github.com/charmbracelet/x/editor v0.1.0 github.com/charmbracelet/x/term v0.2.1 + github.com/charmbracelet/x/xpty v0.1.2 github.com/muesli/roff v0.1.0 github.com/muesli/termenv v0.15.3-0.20241211131612-0d230cb6eb15 github.com/rivo/uniseg v0.4.7 @@ -26,6 +27,10 @@ require ( github.com/atotto/clipboard v0.1.4 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymerick/douceur v0.2.0 // indirect + github.com/charmbracelet/x/conpty v0.1.0 // indirect + github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 // indirect + github.com/charmbracelet/x/termios v0.1.1 // indirect + github.com/creack/pty v1.1.24 // indirect github.com/dlclark/regexp2 v1.11.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect diff --git a/go.sum b/go.sum index a880e19..507875b 100644 --- a/go.sum +++ b/go.sum @@ -32,12 +32,22 @@ github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8 github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= github.com/charmbracelet/x/ansi v0.8.0 h1:9GTq3xq9caJW8ZrBTe0LIe2fvfLR/bYXKTx2llXn7xE= github.com/charmbracelet/x/ansi v0.8.0/go.mod h1:wdYl/ONOLHLIVmQaxbIYEC/cRKOQyjTkowiI4blgS9Q= +github.com/charmbracelet/x/conpty v0.1.0 h1:4zc8KaIcbiL4mghEON8D72agYtSeIgq8FSThSPQIb+U= +github.com/charmbracelet/x/conpty v0.1.0/go.mod h1:rMFsDJoDwVmiYM10aD4bH2XiRgwI7NYJtQgl5yskjEQ= github.com/charmbracelet/x/editor v0.1.0 h1:p69/dpvlwRTs9uYiPeAWruwsHqTFzHhTvQOd/WVSX98= github.com/charmbracelet/x/editor v0.1.0/go.mod h1:oivrEbcP/AYt/Hpvk5pwDXXrQ933gQS6UzL6fxqAGSA= +github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 h1:JSt3B+U9iqk37QUU2Rvb6DSBYRLtWqFqfxf8l5hOZUA= +github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86/go.mod h1:2P0UgXMEa6TsToMSuFqKFQR+fZTO9CNGUNokkPatT/0= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ= github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg= +github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8JawjaNZY= +github.com/charmbracelet/x/termios v0.1.1/go.mod h1:rB7fnv1TgOPOyyKRJ9o+AsTU/vK5WHJ2ivHeut/Pcwo= +github.com/charmbracelet/x/xpty v0.1.2 h1:Pqmu4TEJ8KeA9uSkISKMU3f+C1F6OGBn8ABuGlqCbtI= +github.com/charmbracelet/x/xpty v0.1.2/go.mod h1:XK2Z0id5rtLWcpeNiMYBccNNBrP2IJnzHI0Lq13Xzq4= +github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s= +github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI= diff --git a/spin/command.go b/spin/command.go index 02213f0..08cb3bd 100644 --- a/spin/command.go +++ b/spin/command.go @@ -48,22 +48,29 @@ func (o Options) Run() error { // If the command succeeds, and we are printing output and we are in a TTY then push the STDOUT we got to the actual // STDOUT for piping or other things. //nolint:nestif - if m.status == 0 { - if o.ShowOutput { - // BubbleTea writes the View() to stderr. - // If the program is being piped then put the accumulated output in stdout. - if !isOutTTY { - _, err := os.Stdout.WriteString(m.stdout) - if err != nil { - return fmt.Errorf("failed to write to stdout: %w", err) - } + if m.err != nil { + if _, err := fmt.Fprintf(os.Stderr, "%s\n", m.err.Error()); err != nil { + return fmt.Errorf("failed to write to stdout: %w", err) + } + return exit.ErrExit(1) + } else if m.status == 0 { + var output string + if o.ShowOutput || (o.ShowStdout && o.ShowStderr) { + output = m.output + } else if o.ShowStdout { + output = m.stdout + } else if o.ShowStderr { + output = m.stderr + } + if output != "" { + if _, err := os.Stdout.WriteString(output); err != nil { + return fmt.Errorf("failed to write to stdout: %w", err) } } } else if o.ShowError { // Otherwise if we are showing errors and the command did not exit with a 0 status code then push all of the command // output to the terminal. This way failed commands can be debugged. - _, err := os.Stdout.WriteString(m.output) - if err != nil { + if _, err := os.Stdout.WriteString(m.output); err != nil { return fmt.Errorf("failed to write to stdout: %w", err) } } diff --git a/spin/pty.go b/spin/pty.go new file mode 100644 index 0000000..92dbe84 --- /dev/null +++ b/spin/pty.go @@ -0,0 +1,22 @@ +package spin + +import ( + "os" + + "github.com/charmbracelet/x/term" + "github.com/charmbracelet/x/xpty" +) + +func openPty(f *os.File) (pty xpty.Pty, err error) { + width, height, err := term.GetSize(f.Fd()) + if err != nil { + return nil, err + } + + pty, err = xpty.NewPty(width, height) + if err != nil { + return nil, err + } + + return pty, nil +} diff --git a/spin/spin.go b/spin/spin.go index d675bab..ee7ea7d 100644 --- a/spin/spin.go +++ b/spin/spin.go @@ -15,15 +15,18 @@ package spin import ( + "bytes" + "context" "io" "os" "os/exec" - "strings" + "runtime" "syscall" "github.com/charmbracelet/bubbles/spinner" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/x/term" + "github.com/charmbracelet/x/xpty" ) type model struct { @@ -40,16 +43,19 @@ type model struct { showStdout bool showStderr bool showError bool + err error } var ( - bothbuf strings.Builder - outbuf strings.Builder - errbuf strings.Builder + bothbuf bytes.Buffer + outbuf bytes.Buffer + errbuf bytes.Buffer executing *exec.Cmd ) +type errorMsg error + type finishCommandMsg struct { stdout string stderr string @@ -65,15 +71,51 @@ func commandStart(command []string) tea.Cmd { } executing = exec.Command(command[0], args...) //nolint:gosec - if term.IsTerminal(os.Stdout.Fd()) { + executing.Stdin = os.Stdin + + isTerminal := term.IsTerminal(os.Stdout.Fd()) + + // NOTE(@andreynering): We had issues with Git Bash on Windows + // when it comes to handling PTYs, so we're falling back to + // to redirecting stdout/stderr as usual to avoid issues. + //nolint:nestif + if isTerminal && runtime.GOOS == "windows" { executing.Stdout = io.MultiWriter(&bothbuf, &outbuf) executing.Stderr = io.MultiWriter(&bothbuf, &errbuf) + _ = executing.Run() + } else if isTerminal { + stdoutPty, err := openPty(os.Stdout) + if err != nil { + return errorMsg(err) + } + defer stdoutPty.Close() //nolint:errcheck + + stderrPty, err := openPty(os.Stderr) + if err != nil { + return errorMsg(err) + } + defer stderrPty.Close() //nolint:errcheck + + if outUnixPty, isOutUnixPty := stdoutPty.(*xpty.UnixPty); isOutUnixPty { + executing.Stdout = outUnixPty.Slave() + } + if errUnixPty, isErrUnixPty := stderrPty.(*xpty.UnixPty); isErrUnixPty { + executing.Stderr = errUnixPty.Slave() + } + + go io.Copy(io.MultiWriter(&bothbuf, &outbuf), stdoutPty) //nolint:errcheck + go io.Copy(io.MultiWriter(&bothbuf, &errbuf), stderrPty) //nolint:errcheck + + if err = stdoutPty.Start(executing); err != nil { + return errorMsg(err) + } + _ = xpty.WaitProcess(context.Background(), executing) } else { executing.Stdout = os.Stdout executing.Stderr = os.Stderr + _ = executing.Run() } - executing.Stdin = os.Stdin - _ = executing.Run() + status := executing.ProcessState.ExitCode() if status == -1 { status = 1 @@ -103,6 +145,10 @@ func (m model) Init() tea.Cmd { } func (m model) View() string { + if m.quitting { + return "" + } + var out string if m.showStderr { out += errbuf.String() @@ -111,10 +157,6 @@ func (m model) View() string { out += outbuf.String() } - if m.quitting { - return out - } - if !m.isTTY { return m.title } @@ -129,7 +171,6 @@ func (m model) View() string { } func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { - var cmd tea.Cmd switch msg := msg.(type) { case finishCommandMsg: m.stdout = msg.stdout @@ -143,8 +184,13 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case "ctrl+c": return m, commandAbort } + case errorMsg: + m.err = msg + m.quitting = true + return m, tea.Quit } + var cmd tea.Cmd m.spinner, cmd = m.spinner.Update(msg) return m, cmd } From 2b72e8029773e474802b804b97346cdc640a7346 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Tue, 11 Feb 2025 13:00:03 -0800 Subject: [PATCH 134/198] fix(confirm): ensure `--show-output` show the right answer (#853) --- confirm/command.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/confirm/command.go b/confirm/command.go index ed5cf6e..abbfad9 100644 --- a/confirm/command.go +++ b/confirm/command.go @@ -49,6 +49,7 @@ func (o Options) Run() error { if err != nil { return fmt.Errorf("unable to confirm: %w", err) } + m = tm.(model) if o.ShowOutput { confirmationText := m.negative @@ -58,7 +59,6 @@ func (o Options) Run() error { fmt.Println(m.prompt, confirmationText) } - m = tm.(model) if m.confirmation { return nil } From 24fa527d083e2751f98ebe31941111448762b77a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 12 Feb 2025 04:44:46 +0000 Subject: [PATCH 135/198] chore(deps): bump github.com/charmbracelet/bubbletea from 1.3.2 to 1.3.3 (#854) Bumps [github.com/charmbracelet/bubbletea](https://github.com/charmbracelet/bubbletea) from 1.3.2 to 1.3.3. - [Release notes](https://github.com/charmbracelet/bubbletea/releases) - [Changelog](https://github.com/charmbracelet/bubbletea/blob/main/.goreleaser.yml) - [Commits](https://github.com/charmbracelet/bubbletea/compare/v1.3.2...v1.3.3) --- updated-dependencies: - dependency-name: github.com/charmbracelet/bubbletea dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 3e71643..ce228ce 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/alecthomas/kong v1.8.0 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 - github.com/charmbracelet/bubbletea v1.3.2 + github.com/charmbracelet/bubbletea v1.3.3 github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/lipgloss v1.0.1-0.20250110214317-ecc1bd014d51 github.com/charmbracelet/log v0.4.0 diff --git a/go.sum b/go.sum index 507875b..ec8ff42 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE= github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU= -github.com/charmbracelet/bubbletea v1.3.2 h1:nc+gDivH0P8ii8CUcf3zCN/PiUz7LKbp3Iz+vYPScNY= -github.com/charmbracelet/bubbletea v1.3.2/go.mod h1:dtcUCyCGEX3g9tosuYiut3MXgY/Jsv9nKVdibKKRRXo= +github.com/charmbracelet/bubbletea v1.3.3 h1:WpU6fCY0J2vDWM3zfS3vIDi/ULq3SYphZhkAGGvmEUY= +github.com/charmbracelet/bubbletea v1.3.3/go.mod h1:dtcUCyCGEX3g9tosuYiut3MXgY/Jsv9nKVdibKKRRXo= github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= github.com/charmbracelet/lipgloss v1.0.1-0.20250110214317-ecc1bd014d51 h1:f+0mEkhorXNiBaHb4V9wyd364OH/aF7md7ZngkS+1gU= From 25c40f5ecaf6161f1e1dae2d0c67fe0c24df4204 Mon Sep 17 00:00:00 2001 From: Charm <124303983+charmcli@users.noreply.github.com> Date: Thu, 13 Feb 2025 11:07:04 -0300 Subject: [PATCH 136/198] ci: sync dependabot config (#855) --- .github/dependabot.yml | 25 +++++++++++++++++++++++-- .github/workflows/dependabot-sync.yml | 15 +++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/dependabot-sync.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index c0e481b..cbc9aa4 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,20 +1,41 @@ version: 2 + updates: - package-ecosystem: "gomod" directory: "/" schedule: - interval: "daily" + interval: "weekly" + day: "monday" + time: "05:00" + timezone: "America/New_York" labels: - "dependencies" commit-message: prefix: "chore" include: "scope" + - package-ecosystem: "github-actions" directory: "/" schedule: - interval: "daily" + interval: "weekly" + day: "monday" + time: "05:00" + timezone: "America/New_York" labels: - "dependencies" commit-message: prefix: "chore" include: "scope" + + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "weekly" + day: "monday" + time: "05:00" + timezone: "America/New_York" + labels: + - "dependencies" + commit-message: + prefix: "feat" + include: "scope" diff --git a/.github/workflows/dependabot-sync.yml b/.github/workflows/dependabot-sync.yml new file mode 100644 index 0000000..e5aa74e --- /dev/null +++ b/.github/workflows/dependabot-sync.yml @@ -0,0 +1,15 @@ +name: dependabot-sync +on: + schedule: + - cron: "0 0 * * 0" # every Sunday at midnight + workflow_dispatch: # allows manual triggering + +permissions: + contents: write + pull-requests: write + +jobs: + dependabot-sync: + uses: charmbracelet/meta/.github/workflows/dependabot-sync.yml@main + with: + repo_name: ${{ github.event.repository.name }} From a3975b78eea17663cc6216a25c7be6daf4e69918 Mon Sep 17 00:00:00 2001 From: Charm <124303983+charmcli@users.noreply.github.com> Date: Thu, 13 Feb 2025 11:31:46 -0300 Subject: [PATCH 137/198] ci: sync dependabot config (#856) --- .github/workflows/dependabot-sync.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/dependabot-sync.yml b/.github/workflows/dependabot-sync.yml index e5aa74e..9b08259 100644 --- a/.github/workflows/dependabot-sync.yml +++ b/.github/workflows/dependabot-sync.yml @@ -13,3 +13,5 @@ jobs: uses: charmbracelet/meta/.github/workflows/dependabot-sync.yml@main with: repo_name: ${{ github.event.repository.name }} + secrets: + gh_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} From 308d86be7d4c7628e9f4ddc8d69edb9719f09d8a Mon Sep 17 00:00:00 2001 From: ctn-malone <60197791+ctn-malone@users.noreply.github.com> Date: Sat, 15 Feb 2025 01:08:37 +0100 Subject: [PATCH 138/198] chore(nix): update version and vendor hash (#859) --- default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index 5c14976..511568f 100644 --- a/default.nix +++ b/default.nix @@ -2,11 +2,11 @@ pkgs.buildGoModule rec { pname = "gum"; - version = "0.15.0"; + version = "0.15.2"; src = ./.; - vendorHash = "sha256-i/KBe41ufYA+tqnB5LCC1geIc2Jnh97JLXcXfBgxdM4="; + vendorHash = "sha256-TK2Fc4bTkiSpyYrg4dJOzamEnii03P7kyHZdah9izqY="; ldflags = [ "-s" "-w" "-X=main.Version=${version}" ]; } From 9f503f5335594da27cb854502273b55083e478a2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Feb 2025 11:21:22 +0000 Subject: [PATCH 139/198] chore(deps): bump github.com/alecthomas/kong from 1.8.0 to 1.8.1 (#861) Bumps [github.com/alecthomas/kong](https://github.com/alecthomas/kong) from 1.8.0 to 1.8.1. - [Release notes](https://github.com/alecthomas/kong/releases) - [Commits](https://github.com/alecthomas/kong/compare/v1.8.0...v1.8.1) --- updated-dependencies: - dependency-name: github.com/alecthomas/kong dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ce228ce..5efde30 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.23.0 require ( github.com/Masterminds/semver/v3 v3.3.1 - github.com/alecthomas/kong v1.8.0 + github.com/alecthomas/kong v1.8.1 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 github.com/charmbracelet/bubbletea v1.3.3 diff --git a/go.sum b/go.sum index ec8ff42..96767c2 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8v github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E= github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I= -github.com/alecthomas/kong v1.8.0 h1:LEDIdSYrHU+4oTF2BL0NAfw++wH6lg/LzAJodTkLikM= -github.com/alecthomas/kong v1.8.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= +github.com/alecthomas/kong v1.8.1 h1:6aamvWBE/REnR/BCq10EcozmcpUPc5aGI1lPAWdB0EE= +github.com/alecthomas/kong v1.8.1/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= github.com/alecthomas/mango-kong v0.1.0 h1:iFVfP1k1K4qpml3JUQmD5I8MCQYfIvsD9mRdrw7jJC4= github.com/alecthomas/mango-kong v0.1.0/go.mod h1:t+TYVdsONUolf/BwVcm+15eqcdAj15h4Qe9MMFAwwT4= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= From 85a29801d8f6b031a988a3cc1eebacf27a199f9b Mon Sep 17 00:00:00 2001 From: Abel Chalier Date: Fri, 21 Feb 2025 18:04:30 +0100 Subject: [PATCH 140/198] fix: wildcard escaping issue (#862) --- completion/fish.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/completion/fish.go b/completion/fish.go index 8335356..9fc80d2 100644 --- a/completion/fish.go +++ b/completion/fish.go @@ -79,7 +79,7 @@ func (f Fish) gen(buf io.StringWriter, cmd *kong.Node) { _, _ = buf.WriteString(fmt.Sprintf(" -s %c", f.Short)) } _, _ = buf.WriteString(fmt.Sprintf(" -l %s", f.Name)) - _, _ = buf.WriteString(fmt.Sprintf(" -d '%s'", f.Help)) + _, _ = buf.WriteString(fmt.Sprintf(" -d \"%s\"", f.Help)) _, _ = buf.WriteString("\n") } _, _ = buf.WriteString("\n") From db86a909bb2157b8d340e50dd419eb32e2bf87a7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Feb 2025 11:05:37 +0000 Subject: [PATCH 141/198] chore(deps): bump github.com/muesli/termenv (#865) Bumps [github.com/muesli/termenv](https://github.com/muesli/termenv) from 0.15.3-0.20241211131612-0d230cb6eb15 to 0.16.0. - [Release notes](https://github.com/muesli/termenv/releases) - [Commits](https://github.com/muesli/termenv/commits/v0.16.0) --- updated-dependencies: - dependency-name: github.com/muesli/termenv dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5efde30..c9c7b92 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/charmbracelet/x/term v0.2.1 github.com/charmbracelet/x/xpty v0.1.2 github.com/muesli/roff v0.1.0 - github.com/muesli/termenv v0.15.3-0.20241211131612-0d230cb6eb15 + github.com/muesli/termenv v0.16.0 github.com/rivo/uniseg v0.4.7 github.com/sahilm/fuzzy v0.1.1 golang.org/x/text v0.22.0 diff --git a/go.sum b/go.sum index 96767c2..eb77e5e 100644 --- a/go.sum +++ b/go.sum @@ -85,8 +85,8 @@ github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s= github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8= github.com/muesli/roff v0.1.0 h1:YD0lalCotmYuF5HhZliKWlIx7IEhiXeSfq7hNjFqGF8= github.com/muesli/roff v0.1.0/go.mod h1:pjAHQM9hdUUwm/krAfrLGgJkXJ+YuhtsfZ42kieB2Ig= -github.com/muesli/termenv v0.15.3-0.20241211131612-0d230cb6eb15 h1:XGrI/sVwKFHXvDVSGfan37w1AFt14RLDqBqY0ThTgk0= -github.com/muesli/termenv v0.15.3-0.20241211131612-0d230cb6eb15/go.mod h1:hxSnBBYLK21Vtq/PHd0S2FYCxBXzBua8ov5s1RobyRQ= +github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc= +github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= From dbac6a83f3948b6dd0166e3085b89ec683cf75b1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Mar 2025 10:29:58 +0000 Subject: [PATCH 142/198] chore(deps): bump github.com/charmbracelet/bubbletea from 1.3.3 to 1.3.4 (#866) Bumps [github.com/charmbracelet/bubbletea](https://github.com/charmbracelet/bubbletea) from 1.3.3 to 1.3.4. - [Release notes](https://github.com/charmbracelet/bubbletea/releases) - [Changelog](https://github.com/charmbracelet/bubbletea/blob/main/.goreleaser.yml) - [Commits](https://github.com/charmbracelet/bubbletea/compare/v1.3.3...v1.3.4) --- updated-dependencies: - dependency-name: github.com/charmbracelet/bubbletea dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index c9c7b92..290aad1 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/alecthomas/kong v1.8.1 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 - github.com/charmbracelet/bubbletea v1.3.3 + github.com/charmbracelet/bubbletea v1.3.4 github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/lipgloss v1.0.1-0.20250110214317-ecc1bd014d51 github.com/charmbracelet/log v0.4.0 diff --git a/go.sum b/go.sum index eb77e5e..398c5b6 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE= github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU= -github.com/charmbracelet/bubbletea v1.3.3 h1:WpU6fCY0J2vDWM3zfS3vIDi/ULq3SYphZhkAGGvmEUY= -github.com/charmbracelet/bubbletea v1.3.3/go.mod h1:dtcUCyCGEX3g9tosuYiut3MXgY/Jsv9nKVdibKKRRXo= +github.com/charmbracelet/bubbletea v1.3.4 h1:kCg7B+jSCFPLYRA52SDZjr51kG/fMUEoPoZrkaDHyoI= +github.com/charmbracelet/bubbletea v1.3.4/go.mod h1:dtcUCyCGEX3g9tosuYiut3MXgY/Jsv9nKVdibKKRRXo= github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= github.com/charmbracelet/lipgloss v1.0.1-0.20250110214317-ecc1bd014d51 h1:f+0mEkhorXNiBaHb4V9wyd364OH/aF7md7ZngkS+1gU= From 204d21940eab977fb5ce6bd84742a17c17d404c1 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 5 Mar 2025 23:57:08 -0300 Subject: [PATCH 143/198] fix(choose): order when using --label-delimiter (#867) closes #829 --- choose/command.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/choose/command.go b/choose/command.go index 47e3549..63194f0 100644 --- a/choose/command.go +++ b/choose/command.go @@ -3,7 +3,6 @@ package choose import ( "errors" "fmt" - "maps" "os" "slices" "sort" @@ -38,6 +37,8 @@ func (o Options) Run() error { // normalize options into a map options := map[string]string{} + // keep the labels in the user-provided order + var labels []string for _, opt := range o.Options { if o.LabelDelimiter == "" { options[opt] = opt @@ -47,10 +48,11 @@ func (o Options) Run() error { if !ok { return fmt.Errorf("invalid option format: %q", opt) } + labels = append(labels, label) options[label] = value } if o.LabelDelimiter != "" { - o.Options = slices.Collect(maps.Keys(options)) + o.Options = labels } if o.SelectIfOne && len(o.Options) == 1 { From 0d116b80685eff038aa0d436c87e4f08760ad357 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Mar 2025 09:19:20 +0000 Subject: [PATCH 144/198] chore(deps): bump golang.org/x/text from 0.22.0 to 0.23.0 (#868) Bumps [golang.org/x/text](https://github.com/golang/text) from 0.22.0 to 0.23.0. - [Release notes](https://github.com/golang/text/releases) - [Commits](https://github.com/golang/text/compare/v0.22.0...v0.23.0) --- updated-dependencies: - dependency-name: golang.org/x/text dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 290aad1..3090f1b 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/muesli/termenv v0.16.0 github.com/rivo/uniseg v0.4.7 github.com/sahilm/fuzzy v0.1.1 - golang.org/x/text v0.22.0 + golang.org/x/text v0.23.0 ) require ( @@ -49,7 +49,7 @@ require ( github.com/yuin/goldmark-emoji v1.0.4 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/net v0.33.0 // indirect - golang.org/x/sync v0.11.0 // indirect + golang.org/x/sync v0.12.0 // indirect golang.org/x/sys v0.30.0 // indirect golang.org/x/term v0.27.0 // indirect ) diff --git a/go.sum b/go.sum index 398c5b6..f03cece 100644 --- a/go.sum +++ b/go.sum @@ -106,15 +106,15 @@ golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0J golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= -golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= -golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= +golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= -golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= -golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From a8b94c1c83422498b1b06cbbda2ca42def74df3b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Mar 2025 10:14:18 +0000 Subject: [PATCH 145/198] chore(deps): bump github.com/alecthomas/kong from 1.8.1 to 1.9.0 (#872) Bumps [github.com/alecthomas/kong](https://github.com/alecthomas/kong) from 1.8.1 to 1.9.0. - [Release notes](https://github.com/alecthomas/kong/releases) - [Commits](https://github.com/alecthomas/kong/compare/v1.8.1...v1.9.0) --- updated-dependencies: - dependency-name: github.com/alecthomas/kong dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 +++- go.sum | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 3090f1b..25a10d0 100644 --- a/go.mod +++ b/go.mod @@ -2,9 +2,11 @@ module github.com/charmbracelet/gum go 1.23.0 +toolchain go1.24.1 + require ( github.com/Masterminds/semver/v3 v3.3.1 - github.com/alecthomas/kong v1.8.1 + github.com/alecthomas/kong v1.9.0 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 github.com/charmbracelet/bubbletea v1.3.4 diff --git a/go.sum b/go.sum index f03cece..439a48d 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8v github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E= github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I= -github.com/alecthomas/kong v1.8.1 h1:6aamvWBE/REnR/BCq10EcozmcpUPc5aGI1lPAWdB0EE= -github.com/alecthomas/kong v1.8.1/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= +github.com/alecthomas/kong v1.9.0 h1:Wgg0ll5Ys7xDnpgYBuBn/wPeLGAuK0NvYmEcisJgrIs= +github.com/alecthomas/kong v1.9.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= github.com/alecthomas/mango-kong v0.1.0 h1:iFVfP1k1K4qpml3JUQmD5I8MCQYfIvsD9mRdrw7jJC4= github.com/alecthomas/mango-kong v0.1.0/go.mod h1:t+TYVdsONUolf/BwVcm+15eqcdAj15h4Qe9MMFAwwT4= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= From 7c833f1b753095afe00302b6bce1d13f528ee1e9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Mar 2025 10:15:37 +0000 Subject: [PATCH 146/198] chore(deps): bump github.com/charmbracelet/glamour from 0.8.0 to 0.9.0 (#873) Bumps [github.com/charmbracelet/glamour](https://github.com/charmbracelet/glamour) from 0.8.0 to 0.9.0. - [Release notes](https://github.com/charmbracelet/glamour/releases) - [Changelog](https://github.com/charmbracelet/glamour/blob/master/.goreleaser.yml) - [Commits](https://github.com/charmbracelet/glamour/compare/v0.8.0...v0.9.0) --- updated-dependencies: - dependency-name: github.com/charmbracelet/glamour dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 15 +++++++++------ go.sum | 30 ++++++++++++++++++------------ 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/go.mod b/go.mod index 25a10d0..3f353a9 100644 --- a/go.mod +++ b/go.mod @@ -10,8 +10,8 @@ require ( github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 github.com/charmbracelet/bubbletea v1.3.4 - github.com/charmbracelet/glamour v0.8.0 - github.com/charmbracelet/lipgloss v1.0.1-0.20250110214317-ecc1bd014d51 + github.com/charmbracelet/glamour v0.9.0 + github.com/charmbracelet/lipgloss v1.1.0 github.com/charmbracelet/log v0.4.0 github.com/charmbracelet/x/ansi v0.8.0 github.com/charmbracelet/x/editor v0.1.0 @@ -29,6 +29,8 @@ require ( github.com/atotto/clipboard v0.1.4 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymerick/douceur v0.2.0 // indirect + github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect + github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect github.com/charmbracelet/x/conpty v0.1.0 // indirect github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 // indirect github.com/charmbracelet/x/termios v0.1.1 // indirect @@ -47,11 +49,12 @@ require ( github.com/muesli/cancelreader v0.2.2 // indirect github.com/muesli/mango v0.2.0 // indirect github.com/muesli/reflow v0.3.0 // indirect - github.com/yuin/goldmark v1.7.4 // indirect - github.com/yuin/goldmark-emoji v1.0.4 // indirect + github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect + github.com/yuin/goldmark v1.7.8 // indirect + github.com/yuin/goldmark-emoji v1.0.5 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/net v0.33.0 // indirect golang.org/x/sync v0.12.0 // indirect - golang.org/x/sys v0.30.0 // indirect - golang.org/x/term v0.27.0 // indirect + golang.org/x/sys v0.31.0 // indirect + golang.org/x/term v0.30.0 // indirect ) diff --git a/go.sum b/go.sum index 439a48d..376ac59 100644 --- a/go.sum +++ b/go.sum @@ -24,14 +24,18 @@ github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQW github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU= github.com/charmbracelet/bubbletea v1.3.4 h1:kCg7B+jSCFPLYRA52SDZjr51kG/fMUEoPoZrkaDHyoI= github.com/charmbracelet/bubbletea v1.3.4/go.mod h1:dtcUCyCGEX3g9tosuYiut3MXgY/Jsv9nKVdibKKRRXo= -github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= -github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= -github.com/charmbracelet/lipgloss v1.0.1-0.20250110214317-ecc1bd014d51 h1:f+0mEkhorXNiBaHb4V9wyd364OH/aF7md7ZngkS+1gU= -github.com/charmbracelet/lipgloss v1.0.1-0.20250110214317-ecc1bd014d51/go.mod h1:QRGthpgH59/perglqXZC8xPHqDGZ9BB45ChJCFEWEMI= +github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs= +github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk= +github.com/charmbracelet/glamour v0.9.0 h1:1Hm3wxww7qXvGI+Fb3zDmIZo5oDOvVOWJ4OrIB+ef7c= +github.com/charmbracelet/glamour v0.9.0/go.mod h1:+SHvIS8qnwhgTpVMiXwn7OfGomSqff1cHBCI8jLOetk= +github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY= +github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= github.com/charmbracelet/x/ansi v0.8.0 h1:9GTq3xq9caJW8ZrBTe0LIe2fvfLR/bYXKTx2llXn7xE= github.com/charmbracelet/x/ansi v0.8.0/go.mod h1:wdYl/ONOLHLIVmQaxbIYEC/cRKOQyjTkowiI4blgS9Q= +github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd h1:vy0GVL4jeHEwG5YOXDmi86oYw2yuYUGqz6a8sLwg0X8= +github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs= github.com/charmbracelet/x/conpty v0.1.0 h1:4zc8KaIcbiL4mghEON8D72agYtSeIgq8FSThSPQIb+U= github.com/charmbracelet/x/conpty v0.1.0/go.mod h1:rMFsDJoDwVmiYM10aD4bH2XiRgwI7NYJtQgl5yskjEQ= github.com/charmbracelet/x/editor v0.1.0 h1:p69/dpvlwRTs9uYiPeAWruwsHqTFzHhTvQOd/WVSX98= @@ -97,11 +101,13 @@ github.com/sahilm/fuzzy v0.1.1 h1:ceu5RHF8DGgoi+/dR5PsECjCDH1BE3Fnmpo7aVXOdRA= github.com/sahilm/fuzzy v0.1.1/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= +github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= -github.com/yuin/goldmark v1.7.4 h1:BDXOHExt+A7gwPCJgPIIq7ENvceR7we7rOS9TNoLZeg= -github.com/yuin/goldmark v1.7.4/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= -github.com/yuin/goldmark-emoji v1.0.4 h1:vCwMkPZSNefSUnOW2ZKRUjBSD5Ok3W78IXhGxxAEF90= -github.com/yuin/goldmark-emoji v1.0.4/go.mod h1:tTkZEbwu5wkPmgTcitqddVxY9osFZiavD+r4AzQrh1U= +github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic= +github.com/yuin/goldmark v1.7.8/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= +github.com/yuin/goldmark-emoji v1.0.5 h1:EMVWyCGPlXJfUXBXpuMu+ii3TIaxbVBnEX9uaDC4cIk= +github.com/yuin/goldmark-emoji v1.0.5/go.mod h1:tTkZEbwu5wkPmgTcitqddVxY9osFZiavD+r4AzQrh1U= golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY= golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= @@ -110,10 +116,10 @@ golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= -golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= -golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= +golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= +golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y= +golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g= golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= From 93c6a4bf1f432a2232768e0f2b682d3c119c25a2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Mar 2025 10:19:46 +0000 Subject: [PATCH 147/198] chore(deps): bump github.com/charmbracelet/log from 0.4.0 to 0.4.1 (#874) Bumps [github.com/charmbracelet/log](https://github.com/charmbracelet/log) from 0.4.0 to 0.4.1. - [Release notes](https://github.com/charmbracelet/log/releases) - [Commits](https://github.com/charmbracelet/log/compare/v0.4.0...v0.4.1) --- updated-dependencies: - dependency-name: github.com/charmbracelet/log dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 3f353a9..26f253f 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/charmbracelet/bubbletea v1.3.4 github.com/charmbracelet/glamour v0.9.0 github.com/charmbracelet/lipgloss v1.1.0 - github.com/charmbracelet/log v0.4.0 + github.com/charmbracelet/log v0.4.1 github.com/charmbracelet/x/ansi v0.8.0 github.com/charmbracelet/x/editor v0.1.0 github.com/charmbracelet/x/term v0.2.1 diff --git a/go.sum b/go.sum index 376ac59..bcab5fc 100644 --- a/go.sum +++ b/go.sum @@ -30,8 +30,8 @@ github.com/charmbracelet/glamour v0.9.0 h1:1Hm3wxww7qXvGI+Fb3zDmIZo5oDOvVOWJ4OrI github.com/charmbracelet/glamour v0.9.0/go.mod h1:+SHvIS8qnwhgTpVMiXwn7OfGomSqff1cHBCI8jLOetk= github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY= github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30= -github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= -github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= +github.com/charmbracelet/log v0.4.1 h1:6AYnoHKADkghm/vt4neaNEXkxcXLSV2g1rdyFDOpTyk= +github.com/charmbracelet/log v0.4.1/go.mod h1:pXgyTsqsVu4N9hGdHmQ0xEA4RsXof402LX9ZgiITn2I= github.com/charmbracelet/x/ansi v0.8.0 h1:9GTq3xq9caJW8ZrBTe0LIe2fvfLR/bYXKTx2llXn7xE= github.com/charmbracelet/x/ansi v0.8.0/go.mod h1:wdYl/ONOLHLIVmQaxbIYEC/cRKOQyjTkowiI4blgS9Q= github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd h1:vy0GVL4jeHEwG5YOXDmi86oYw2yuYUGqz6a8sLwg0X8= @@ -99,8 +99,8 @@ github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/sahilm/fuzzy v0.1.1 h1:ceu5RHF8DGgoi+/dR5PsECjCDH1BE3Fnmpo7aVXOdRA= github.com/sahilm/fuzzy v0.1.1/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= From 699ac86e9a9186ae1fff38fc67651e72649803f6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Mar 2025 10:16:06 +0000 Subject: [PATCH 148/198] chore(deps): bump github.com/charmbracelet/glamour from 0.9.0 to 0.9.1 (#878) Bumps [github.com/charmbracelet/glamour](https://github.com/charmbracelet/glamour) from 0.9.0 to 0.9.1. - [Release notes](https://github.com/charmbracelet/glamour/releases) - [Changelog](https://github.com/charmbracelet/glamour/blob/master/.goreleaser.yml) - [Commits](https://github.com/charmbracelet/glamour/compare/v0.9.0...v0.9.1) --- updated-dependencies: - dependency-name: github.com/charmbracelet/glamour dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 26f253f..8e8a1f5 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 github.com/charmbracelet/bubbletea v1.3.4 - github.com/charmbracelet/glamour v0.9.0 + github.com/charmbracelet/glamour v0.9.1 github.com/charmbracelet/lipgloss v1.1.0 github.com/charmbracelet/log v0.4.1 github.com/charmbracelet/x/ansi v0.8.0 diff --git a/go.sum b/go.sum index bcab5fc..84eb0f4 100644 --- a/go.sum +++ b/go.sum @@ -26,8 +26,8 @@ github.com/charmbracelet/bubbletea v1.3.4 h1:kCg7B+jSCFPLYRA52SDZjr51kG/fMUEoPoZ github.com/charmbracelet/bubbletea v1.3.4/go.mod h1:dtcUCyCGEX3g9tosuYiut3MXgY/Jsv9nKVdibKKRRXo= github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs= github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk= -github.com/charmbracelet/glamour v0.9.0 h1:1Hm3wxww7qXvGI+Fb3zDmIZo5oDOvVOWJ4OrIB+ef7c= -github.com/charmbracelet/glamour v0.9.0/go.mod h1:+SHvIS8qnwhgTpVMiXwn7OfGomSqff1cHBCI8jLOetk= +github.com/charmbracelet/glamour v0.9.1 h1:11dEfiGP8q1BEqvGoIjivuc2rBk+5qEXdPtaQ2WoiCM= +github.com/charmbracelet/glamour v0.9.1/go.mod h1:+SHvIS8qnwhgTpVMiXwn7OfGomSqff1cHBCI8jLOetk= github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY= github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30= github.com/charmbracelet/log v0.4.1 h1:6AYnoHKADkghm/vt4neaNEXkxcXLSV2g1rdyFDOpTyk= From 4fea9a037ade974139d32a83c0955e96331e75a5 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 25 Mar 2025 14:00:20 -0300 Subject: [PATCH 149/198] fix: make empty line before help consistent --- choose/choose.go | 2 +- write/write.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/choose/choose.go b/choose/choose.go index 6594676..48f8857 100644 --- a/choose/choose.go +++ b/choose/choose.go @@ -277,7 +277,7 @@ func (m model) View() string { } parts = append(parts, s.String()) if m.showHelp { - parts = append(parts, m.help.View(m.keymap)) + parts = append(parts, "", m.help.View(m.keymap)) } return lipgloss.JoinVertical(lipgloss.Left, parts...) diff --git a/write/write.go b/write/write.go index 978bf0d..323dc91 100644 --- a/write/write.go +++ b/write/write.go @@ -94,7 +94,7 @@ func (m model) View() string { } parts = append(parts, m.textarea.View()) if m.showHelp { - parts = append(parts, m.help.View(m.keymap)) + parts = append(parts, "", m.help.View(m.keymap)) } return lipgloss.JoinVertical(lipgloss.Left, parts...) } From 33b4e03e669d8ef5a2a5bf18c966df5c9889316a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Mar 2025 09:49:29 +0000 Subject: [PATCH 150/198] chore(deps): bump golangci/golangci-lint-action from 6 to 7 (#882) Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 6 to 7. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](https://github.com/golangci/golangci-lint-action/compare/v6...v7) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/lint-soft.yml | 2 +- .github/workflows/lint.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint-soft.yml b/.github/workflows/lint-soft.yml index 87d1e1f..b57e6df 100644 --- a/.github/workflows/lint-soft.yml +++ b/.github/workflows/lint-soft.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v4 - name: golangci-lint - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v7 with: # Optional: golangci-lint command line arguments. args: --config .golangci-soft.yml --issues-exit-code=0 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f617a5a..e6dbc1d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v4 - name: golangci-lint - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v7 with: # Optional: golangci-lint command line arguments. #args: From cae32e76b141e8eabe7cf933fcc01e0a42451268 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 09:45:12 +0000 Subject: [PATCH 151/198] chore(deps): bump github.com/alecthomas/kong from 1.9.0 to 1.10.0 (#885) Bumps [github.com/alecthomas/kong](https://github.com/alecthomas/kong) from 1.9.0 to 1.10.0. - [Commits](https://github.com/alecthomas/kong/compare/v1.9.0...v1.10.0) --- updated-dependencies: - dependency-name: github.com/alecthomas/kong dependency-version: 1.10.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 8e8a1f5..17b13fc 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ toolchain go1.24.1 require ( github.com/Masterminds/semver/v3 v3.3.1 - github.com/alecthomas/kong v1.9.0 + github.com/alecthomas/kong v1.10.0 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.20.0 github.com/charmbracelet/bubbletea v1.3.4 diff --git a/go.sum b/go.sum index 84eb0f4..7b83bcb 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8v github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E= github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I= -github.com/alecthomas/kong v1.9.0 h1:Wgg0ll5Ys7xDnpgYBuBn/wPeLGAuK0NvYmEcisJgrIs= -github.com/alecthomas/kong v1.9.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= +github.com/alecthomas/kong v1.10.0 h1:8K4rGDpT7Iu+jEXCIJUeKqvpwZHbsFRoebLbnzlmrpw= +github.com/alecthomas/kong v1.10.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= github.com/alecthomas/mango-kong v0.1.0 h1:iFVfP1k1K4qpml3JUQmD5I8MCQYfIvsD9mRdrw7jJC4= github.com/alecthomas/mango-kong v0.1.0/go.mod h1:t+TYVdsONUolf/BwVcm+15eqcdAj15h4Qe9MMFAwwT4= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= From e43b2772402540017ef98b864d44bbe4123a8aba Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 09:45:36 +0000 Subject: [PATCH 152/198] chore(deps): bump golang.org/x/text from 0.23.0 to 0.24.0 (#884) Bumps [golang.org/x/text](https://github.com/golang/text) from 0.23.0 to 0.24.0. - [Release notes](https://github.com/golang/text/releases) - [Commits](https://github.com/golang/text/compare/v0.23.0...v0.24.0) --- updated-dependencies: - dependency-name: golang.org/x/text dependency-version: 0.24.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 17b13fc..7593638 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/muesli/termenv v0.16.0 github.com/rivo/uniseg v0.4.7 github.com/sahilm/fuzzy v0.1.1 - golang.org/x/text v0.23.0 + golang.org/x/text v0.24.0 ) require ( @@ -54,7 +54,7 @@ require ( github.com/yuin/goldmark-emoji v1.0.5 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/net v0.33.0 // indirect - golang.org/x/sync v0.12.0 // indirect + golang.org/x/sync v0.13.0 // indirect golang.org/x/sys v0.31.0 // indirect golang.org/x/term v0.30.0 // indirect ) diff --git a/go.sum b/go.sum index 7b83bcb..f390732 100644 --- a/go.sum +++ b/go.sum @@ -112,15 +112,15 @@ golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0J golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= -golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= -golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= +golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y= golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g= -golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= -golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= +golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From e292bbf0494520b2b1a6bebb0f4fa9c6510524b5 Mon Sep 17 00:00:00 2001 From: Miguel Ibars <43891734+mikybars@users.noreply.github.com> Date: Fri, 11 Apr 2025 06:46:49 -0700 Subject: [PATCH 153/198] fix: detect timeout error and apply default option (#888) --- confirm/command.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/confirm/command.go b/confirm/command.go index abbfad9..e1f30bc 100644 --- a/confirm/command.go +++ b/confirm/command.go @@ -1,6 +1,7 @@ package confirm import ( + "context" "fmt" "os" @@ -46,7 +47,7 @@ func (o Options) Run() error { tea.WithOutput(os.Stderr), tea.WithContext(ctx), ).Run() - if err != nil { + if err != nil && ctx.Err() != context.DeadlineExceeded { return fmt.Errorf("unable to confirm: %w", err) } m = tm.(model) From b7df657549cf2b045fb84873ddcf8c4a5a407b4b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 09:36:19 +0000 Subject: [PATCH 154/198] chore(deps): bump github.com/charmbracelet/bubbles from 0.20.0 to 0.21.0 (#890) Bumps [github.com/charmbracelet/bubbles](https://github.com/charmbracelet/bubbles) from 0.20.0 to 0.21.0. - [Release notes](https://github.com/charmbracelet/bubbles/releases) - [Changelog](https://github.com/charmbracelet/bubbles/blob/master/.goreleaser.yml) - [Commits](https://github.com/charmbracelet/bubbles/compare/v0.20.0...v0.21.0) --- updated-dependencies: - dependency-name: github.com/charmbracelet/bubbles dependency-version: 0.21.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 7593638..52dd831 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/Masterminds/semver/v3 v3.3.1 github.com/alecthomas/kong v1.10.0 github.com/alecthomas/mango-kong v0.1.0 - github.com/charmbracelet/bubbles v0.20.0 + github.com/charmbracelet/bubbles v0.21.0 github.com/charmbracelet/bubbletea v1.3.4 github.com/charmbracelet/glamour v0.9.1 github.com/charmbracelet/lipgloss v1.1.0 diff --git a/go.sum b/go.sum index f390732..76e5152 100644 --- a/go.sum +++ b/go.sum @@ -20,8 +20,8 @@ github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWp github.com/aymanbagabas/go-udiff v0.2.0/go.mod h1:RE4Ex0qsGkTAJoQdQQCA0uG+nAzJO/pI/QwceO5fgrA= github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= -github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE= -github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU= +github.com/charmbracelet/bubbles v0.21.0 h1:9TdC97SdRVg/1aaXNVWfFH3nnLAwOXr8Fn6u6mfQdFs= +github.com/charmbracelet/bubbles v0.21.0/go.mod h1:HF+v6QUR4HkEpz62dx7ym2xc71/KBHg+zKwJtMw+qtg= github.com/charmbracelet/bubbletea v1.3.4 h1:kCg7B+jSCFPLYRA52SDZjr51kG/fMUEoPoZrkaDHyoI= github.com/charmbracelet/bubbletea v1.3.4/go.mod h1:dtcUCyCGEX3g9tosuYiut3MXgY/Jsv9nKVdibKKRRXo= github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs= @@ -42,8 +42,8 @@ github.com/charmbracelet/x/editor v0.1.0 h1:p69/dpvlwRTs9uYiPeAWruwsHqTFzHhTvQOd github.com/charmbracelet/x/editor v0.1.0/go.mod h1:oivrEbcP/AYt/Hpvk5pwDXXrQ933gQS6UzL6fxqAGSA= github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 h1:JSt3B+U9iqk37QUU2Rvb6DSBYRLtWqFqfxf8l5hOZUA= github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86/go.mod h1:2P0UgXMEa6TsToMSuFqKFQR+fZTO9CNGUNokkPatT/0= -github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q= -github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= +github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 h1:payRxjMjKgx2PaCWLZ4p3ro9y97+TVLZNaRZgJwSVDQ= +github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ= github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg= github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8JawjaNZY= From 1baa8286e996ec134ab4201495e34526c35fa82b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Apr 2025 10:56:43 +0000 Subject: [PATCH 155/198] chore(deps): bump github.com/charmbracelet/glamour from 0.9.1 to 0.10.0 (#893) Bumps [github.com/charmbracelet/glamour](https://github.com/charmbracelet/glamour) from 0.9.1 to 0.10.0. - [Release notes](https://github.com/charmbracelet/glamour/releases) - [Changelog](https://github.com/charmbracelet/glamour/blob/master/.goreleaser.yml) - [Commits](https://github.com/charmbracelet/glamour/compare/v0.9.1...v0.10.0) --- updated-dependencies: - dependency-name: github.com/charmbracelet/glamour dependency-version: 0.10.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 11 ++++++----- go.sum | 22 ++++++++++++---------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index 52dd831..100a224 100644 --- a/go.mod +++ b/go.mod @@ -10,8 +10,8 @@ require ( github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.21.0 github.com/charmbracelet/bubbletea v1.3.4 - github.com/charmbracelet/glamour v0.9.1 - github.com/charmbracelet/lipgloss v1.1.0 + github.com/charmbracelet/glamour v0.10.0 + github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 github.com/charmbracelet/log v0.4.1 github.com/charmbracelet/x/ansi v0.8.0 github.com/charmbracelet/x/editor v0.1.0 @@ -30,9 +30,10 @@ require ( github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymerick/douceur v0.2.0 // indirect github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect - github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect + github.com/charmbracelet/x/cellbuf v0.0.13 // indirect github.com/charmbracelet/x/conpty v0.1.0 // indirect github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 // indirect + github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf // indirect github.com/charmbracelet/x/termios v0.1.1 // indirect github.com/creack/pty v1.1.24 // indirect github.com/dlclark/regexp2 v1.11.0 // indirect @@ -55,6 +56,6 @@ require ( golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/net v0.33.0 // indirect golang.org/x/sync v0.13.0 // indirect - golang.org/x/sys v0.31.0 // indirect - golang.org/x/term v0.30.0 // indirect + golang.org/x/sys v0.32.0 // indirect + golang.org/x/term v0.31.0 // indirect ) diff --git a/go.sum b/go.sum index 76e5152..cfc6430 100644 --- a/go.sum +++ b/go.sum @@ -26,16 +26,16 @@ github.com/charmbracelet/bubbletea v1.3.4 h1:kCg7B+jSCFPLYRA52SDZjr51kG/fMUEoPoZ github.com/charmbracelet/bubbletea v1.3.4/go.mod h1:dtcUCyCGEX3g9tosuYiut3MXgY/Jsv9nKVdibKKRRXo= github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs= github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk= -github.com/charmbracelet/glamour v0.9.1 h1:11dEfiGP8q1BEqvGoIjivuc2rBk+5qEXdPtaQ2WoiCM= -github.com/charmbracelet/glamour v0.9.1/go.mod h1:+SHvIS8qnwhgTpVMiXwn7OfGomSqff1cHBCI8jLOetk= -github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY= -github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30= +github.com/charmbracelet/glamour v0.10.0 h1:MtZvfwsYCx8jEPFJm3rIBFIMZUfUJ765oX8V6kXldcY= +github.com/charmbracelet/glamour v0.10.0/go.mod h1:f+uf+I/ChNmqo087elLnVdCiVgjSKWuXa/l6NU2ndYk= +github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 h1:ZR7e0ro+SZZiIZD7msJyA+NjkCNNavuiPBLgerbOziE= +github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834/go.mod h1:aKC/t2arECF6rNOnaKaVU6y4t4ZeHQzqfxedE/VkVhA= github.com/charmbracelet/log v0.4.1 h1:6AYnoHKADkghm/vt4neaNEXkxcXLSV2g1rdyFDOpTyk= github.com/charmbracelet/log v0.4.1/go.mod h1:pXgyTsqsVu4N9hGdHmQ0xEA4RsXof402LX9ZgiITn2I= github.com/charmbracelet/x/ansi v0.8.0 h1:9GTq3xq9caJW8ZrBTe0LIe2fvfLR/bYXKTx2llXn7xE= github.com/charmbracelet/x/ansi v0.8.0/go.mod h1:wdYl/ONOLHLIVmQaxbIYEC/cRKOQyjTkowiI4blgS9Q= -github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd h1:vy0GVL4jeHEwG5YOXDmi86oYw2yuYUGqz6a8sLwg0X8= -github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs= +github.com/charmbracelet/x/cellbuf v0.0.13 h1:/KBBKHuVRbq1lYx5BzEHBAFBP8VcQzJejZ/IA3iR28k= +github.com/charmbracelet/x/cellbuf v0.0.13/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs= github.com/charmbracelet/x/conpty v0.1.0 h1:4zc8KaIcbiL4mghEON8D72agYtSeIgq8FSThSPQIb+U= github.com/charmbracelet/x/conpty v0.1.0/go.mod h1:rMFsDJoDwVmiYM10aD4bH2XiRgwI7NYJtQgl5yskjEQ= github.com/charmbracelet/x/editor v0.1.0 h1:p69/dpvlwRTs9uYiPeAWruwsHqTFzHhTvQOd/WVSX98= @@ -44,6 +44,8 @@ github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 h1:JSt3B+U9 github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86/go.mod h1:2P0UgXMEa6TsToMSuFqKFQR+fZTO9CNGUNokkPatT/0= github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 h1:payRxjMjKgx2PaCWLZ4p3ro9y97+TVLZNaRZgJwSVDQ= github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= +github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf h1:rLG0Yb6MQSDKdB52aGX55JT1oi0P0Kuaj7wi1bLUpnI= +github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf/go.mod h1:B3UgsnsBZS/eX42BlaNiJkD1pPOUa+oF1IYC6Yd2CEU= github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ= github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg= github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8JawjaNZY= @@ -116,10 +118,10 @@ golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y= -golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g= +golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= +golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/term v0.31.0 h1:erwDkOK1Msy6offm1mOgvspSkslFnIGsFnxOKoufg3o= +golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw= golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= From 6682e2079bee12358a2123b5aedd3e849b69a76d Mon Sep 17 00:00:00 2001 From: Charm <124303983+charmcli@users.noreply.github.com> Date: Mon, 28 Apr 2025 08:44:21 -0300 Subject: [PATCH 156/198] ci: sync dependabot config (#896) --- .github/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index cbc9aa4..63ed01f 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -37,5 +37,5 @@ updates: labels: - "dependencies" commit-message: - prefix: "feat" + prefix: "chore" include: "scope" From 39290a03b4dee358daf3abea6d2d3537e2731cdc Mon Sep 17 00:00:00 2001 From: haya14busa Date: Wed, 30 Apr 2025 20:43:13 +0900 Subject: [PATCH 157/198] docs: use `$EDITOR` instead of `EDITOR` (#897) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 04b14af..e3129f3 100644 --- a/README.md +++ b/README.md @@ -264,7 +264,7 @@ gum confirm && rm file.txt || echo "File not removed" Prompt the user to select a file from the file tree. ```bash -EDITOR $(gum file $HOME) +$EDITOR $(gum file $HOME) ``` Shell running gum file From 9904967fb0437621aabd474386d5aa3fa6e84555 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 May 2025 10:02:08 +0000 Subject: [PATCH 158/198] chore(deps): bump github.com/charmbracelet/x/ansi from 0.8.0 to 0.9.2 (#900) Bumps [github.com/charmbracelet/x/ansi](https://github.com/charmbracelet/x) from 0.8.0 to 0.9.2. - [Commits](https://github.com/charmbracelet/x/compare/ansi/v0.8.0...ansi/v0.9.2) --- updated-dependencies: - dependency-name: github.com/charmbracelet/x/ansi dependency-version: 0.9.2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 100a224..ce72117 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/charmbracelet/glamour v0.10.0 github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 github.com/charmbracelet/log v0.4.1 - github.com/charmbracelet/x/ansi v0.8.0 + github.com/charmbracelet/x/ansi v0.9.2 github.com/charmbracelet/x/editor v0.1.0 github.com/charmbracelet/x/term v0.2.1 github.com/charmbracelet/x/xpty v0.1.2 diff --git a/go.sum b/go.sum index cfc6430..d564e62 100644 --- a/go.sum +++ b/go.sum @@ -32,8 +32,8 @@ github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 h1:ZR7e0r github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834/go.mod h1:aKC/t2arECF6rNOnaKaVU6y4t4ZeHQzqfxedE/VkVhA= github.com/charmbracelet/log v0.4.1 h1:6AYnoHKADkghm/vt4neaNEXkxcXLSV2g1rdyFDOpTyk= github.com/charmbracelet/log v0.4.1/go.mod h1:pXgyTsqsVu4N9hGdHmQ0xEA4RsXof402LX9ZgiITn2I= -github.com/charmbracelet/x/ansi v0.8.0 h1:9GTq3xq9caJW8ZrBTe0LIe2fvfLR/bYXKTx2llXn7xE= -github.com/charmbracelet/x/ansi v0.8.0/go.mod h1:wdYl/ONOLHLIVmQaxbIYEC/cRKOQyjTkowiI4blgS9Q= +github.com/charmbracelet/x/ansi v0.9.2 h1:92AGsQmNTRMzuzHEYfCdjQeUzTrgE1vfO5/7fEVoXdY= +github.com/charmbracelet/x/ansi v0.9.2/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE= github.com/charmbracelet/x/cellbuf v0.0.13 h1:/KBBKHuVRbq1lYx5BzEHBAFBP8VcQzJejZ/IA3iR28k= github.com/charmbracelet/x/cellbuf v0.0.13/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs= github.com/charmbracelet/x/conpty v0.1.0 h1:4zc8KaIcbiL4mghEON8D72agYtSeIgq8FSThSPQIb+U= From 78f18cb5dacafe96c05f3d9193b04631c89ef0ee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 May 2025 10:06:43 +0000 Subject: [PATCH 159/198] chore(deps): bump github.com/charmbracelet/bubbletea from 1.3.4 to 1.3.5 (#901) Bumps [github.com/charmbracelet/bubbletea](https://github.com/charmbracelet/bubbletea) from 1.3.4 to 1.3.5. - [Release notes](https://github.com/charmbracelet/bubbletea/releases) - [Changelog](https://github.com/charmbracelet/bubbletea/blob/main/.goreleaser.yml) - [Commits](https://github.com/charmbracelet/bubbletea/compare/v1.3.4...v1.3.5) --- updated-dependencies: - dependency-name: github.com/charmbracelet/bubbletea dependency-version: 1.3.5 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ce72117..511892b 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/alecthomas/kong v1.10.0 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.21.0 - github.com/charmbracelet/bubbletea v1.3.4 + github.com/charmbracelet/bubbletea v1.3.5 github.com/charmbracelet/glamour v0.10.0 github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 github.com/charmbracelet/log v0.4.1 diff --git a/go.sum b/go.sum index d564e62..39aef11 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/charmbracelet/bubbles v0.21.0 h1:9TdC97SdRVg/1aaXNVWfFH3nnLAwOXr8Fn6u6mfQdFs= github.com/charmbracelet/bubbles v0.21.0/go.mod h1:HF+v6QUR4HkEpz62dx7ym2xc71/KBHg+zKwJtMw+qtg= -github.com/charmbracelet/bubbletea v1.3.4 h1:kCg7B+jSCFPLYRA52SDZjr51kG/fMUEoPoZrkaDHyoI= -github.com/charmbracelet/bubbletea v1.3.4/go.mod h1:dtcUCyCGEX3g9tosuYiut3MXgY/Jsv9nKVdibKKRRXo= +github.com/charmbracelet/bubbletea v1.3.5 h1:JAMNLTbqMOhSwoELIr0qyP4VidFq72/6E9j7HHmRKQc= +github.com/charmbracelet/bubbletea v1.3.5/go.mod h1:TkCnmH+aBd4LrXhXcqrKiYwRs7qyQx5rBgH5fVY3v54= github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs= github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk= github.com/charmbracelet/glamour v0.10.0 h1:MtZvfwsYCx8jEPFJm3rIBFIMZUfUJ765oX8V6kXldcY= From 02bc801b9ffa43e3b377b9c9c7a1b2f5d53b589d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 May 2025 10:12:15 +0000 Subject: [PATCH 160/198] chore(deps): bump golangci/golangci-lint-action from 7 to 8 (#902) Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 7 to 8. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](https://github.com/golangci/golangci-lint-action/compare/v7...v8) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-version: '8' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/lint-soft.yml | 2 +- .github/workflows/lint.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint-soft.yml b/.github/workflows/lint-soft.yml index b57e6df..1c760c4 100644 --- a/.github/workflows/lint-soft.yml +++ b/.github/workflows/lint-soft.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v4 - name: golangci-lint - uses: golangci/golangci-lint-action@v7 + uses: golangci/golangci-lint-action@v8 with: # Optional: golangci-lint command line arguments. args: --config .golangci-soft.yml --issues-exit-code=0 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e6dbc1d..6d24b1a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v4 - name: golangci-lint - uses: golangci/golangci-lint-action@v7 + uses: golangci/golangci-lint-action@v8 with: # Optional: golangci-lint command line arguments. #args: From dd906d93633d877ae48fc2f469fb694119e067d6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 May 2025 10:14:41 +0000 Subject: [PATCH 161/198] chore(deps): bump golang.org/x/text from 0.24.0 to 0.25.0 (#904) Bumps [golang.org/x/text](https://github.com/golang/text) from 0.24.0 to 0.25.0. - [Release notes](https://github.com/golang/text/releases) - [Commits](https://github.com/golang/text/compare/v0.24.0...v0.25.0) --- updated-dependencies: - dependency-name: golang.org/x/text dependency-version: 0.25.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 511892b..812b4df 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/muesli/termenv v0.16.0 github.com/rivo/uniseg v0.4.7 github.com/sahilm/fuzzy v0.1.1 - golang.org/x/text v0.24.0 + golang.org/x/text v0.25.0 ) require ( @@ -55,7 +55,7 @@ require ( github.com/yuin/goldmark-emoji v1.0.5 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/net v0.33.0 // indirect - golang.org/x/sync v0.13.0 // indirect + golang.org/x/sync v0.14.0 // indirect golang.org/x/sys v0.32.0 // indirect golang.org/x/term v0.31.0 // indirect ) diff --git a/go.sum b/go.sum index 39aef11..bc487ce 100644 --- a/go.sum +++ b/go.sum @@ -114,15 +114,15 @@ golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0J golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= -golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= -golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= +golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.31.0 h1:erwDkOK1Msy6offm1mOgvspSkslFnIGsFnxOKoufg3o= golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw= -golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= -golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= +golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= +golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From bb3aaf35e78317945a2e587428aeea5a63cde5b0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 May 2025 09:57:48 +0000 Subject: [PATCH 162/198] chore(deps): bump github.com/alecthomas/kong from 1.10.0 to 1.11.0 (#905) Bumps [github.com/alecthomas/kong](https://github.com/alecthomas/kong) from 1.10.0 to 1.11.0. - [Commits](https://github.com/alecthomas/kong/compare/v1.10.0...v1.11.0) --- updated-dependencies: - dependency-name: github.com/alecthomas/kong dependency-version: 1.11.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 812b4df..056bb32 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ toolchain go1.24.1 require ( github.com/Masterminds/semver/v3 v3.3.1 - github.com/alecthomas/kong v1.10.0 + github.com/alecthomas/kong v1.11.0 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.21.0 github.com/charmbracelet/bubbletea v1.3.5 diff --git a/go.sum b/go.sum index bc487ce..13f447f 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8v github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E= github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I= -github.com/alecthomas/kong v1.10.0 h1:8K4rGDpT7Iu+jEXCIJUeKqvpwZHbsFRoebLbnzlmrpw= -github.com/alecthomas/kong v1.10.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= +github.com/alecthomas/kong v1.11.0 h1:y++1gI7jf8O7G7l4LZo5ASFhrhJvzc+WgF/arranEmM= +github.com/alecthomas/kong v1.11.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= github.com/alecthomas/mango-kong v0.1.0 h1:iFVfP1k1K4qpml3JUQmD5I8MCQYfIvsD9mRdrw7jJC4= github.com/alecthomas/mango-kong v0.1.0/go.mod h1:t+TYVdsONUolf/BwVcm+15eqcdAj15h4Qe9MMFAwwT4= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= From 6f5dfd811717a9c7763c11b45d8276342dfe9f36 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 May 2025 09:58:35 +0000 Subject: [PATCH 163/198] chore(deps): bump github.com/charmbracelet/log from 0.4.1 to 0.4.2 (#906) Bumps [github.com/charmbracelet/log](https://github.com/charmbracelet/log) from 0.4.1 to 0.4.2. - [Release notes](https://github.com/charmbracelet/log/releases) - [Commits](https://github.com/charmbracelet/log/compare/v0.4.1...v0.4.2) --- updated-dependencies: - dependency-name: github.com/charmbracelet/log dependency-version: 0.4.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 056bb32..4639bf8 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/charmbracelet/bubbletea v1.3.5 github.com/charmbracelet/glamour v0.10.0 github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 - github.com/charmbracelet/log v0.4.1 + github.com/charmbracelet/log v0.4.2 github.com/charmbracelet/x/ansi v0.9.2 github.com/charmbracelet/x/editor v0.1.0 github.com/charmbracelet/x/term v0.2.1 diff --git a/go.sum b/go.sum index 13f447f..9b2c97e 100644 --- a/go.sum +++ b/go.sum @@ -30,8 +30,8 @@ github.com/charmbracelet/glamour v0.10.0 h1:MtZvfwsYCx8jEPFJm3rIBFIMZUfUJ765oX8V github.com/charmbracelet/glamour v0.10.0/go.mod h1:f+uf+I/ChNmqo087elLnVdCiVgjSKWuXa/l6NU2ndYk= github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 h1:ZR7e0ro+SZZiIZD7msJyA+NjkCNNavuiPBLgerbOziE= github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834/go.mod h1:aKC/t2arECF6rNOnaKaVU6y4t4ZeHQzqfxedE/VkVhA= -github.com/charmbracelet/log v0.4.1 h1:6AYnoHKADkghm/vt4neaNEXkxcXLSV2g1rdyFDOpTyk= -github.com/charmbracelet/log v0.4.1/go.mod h1:pXgyTsqsVu4N9hGdHmQ0xEA4RsXof402LX9ZgiITn2I= +github.com/charmbracelet/log v0.4.2 h1:hYt8Qj6a8yLnvR+h7MwsJv/XvmBJXiueUcI3cIxsyig= +github.com/charmbracelet/log v0.4.2/go.mod h1:qifHGX/tc7eluv2R6pWIpyHDDrrb/AG71Pf2ysQu5nw= github.com/charmbracelet/x/ansi v0.9.2 h1:92AGsQmNTRMzuzHEYfCdjQeUzTrgE1vfO5/7fEVoXdY= github.com/charmbracelet/x/ansi v0.9.2/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE= github.com/charmbracelet/x/cellbuf v0.0.13 h1:/KBBKHuVRbq1lYx5BzEHBAFBP8VcQzJejZ/IA3iR28k= From 3bc854e26851ab7249dd0a09c655f8eaf8c9cc56 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 30 May 2025 09:57:27 -0300 Subject: [PATCH 164/198] chore(deps): update x/net, x/sys, x/term Signed-off-by: Carlos Alexandro Becker --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 4639bf8..12e81cd 100644 --- a/go.mod +++ b/go.mod @@ -54,8 +54,8 @@ require ( github.com/yuin/goldmark v1.7.8 // indirect github.com/yuin/goldmark-emoji v1.0.5 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect - golang.org/x/net v0.33.0 // indirect + golang.org/x/net v0.40.0 // indirect golang.org/x/sync v0.14.0 // indirect - golang.org/x/sys v0.32.0 // indirect - golang.org/x/term v0.31.0 // indirect + golang.org/x/sys v0.33.0 // indirect + golang.org/x/term v0.32.0 // indirect ) diff --git a/go.sum b/go.sum index 9b2c97e..45024f1 100644 --- a/go.sum +++ b/go.sum @@ -112,16 +112,16 @@ github.com/yuin/goldmark-emoji v1.0.5 h1:EMVWyCGPlXJfUXBXpuMu+ii3TIaxbVBnEX9uaDC github.com/yuin/goldmark-emoji v1.0.5/go.mod h1:tTkZEbwu5wkPmgTcitqddVxY9osFZiavD+r4AzQrh1U= golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY= golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= +golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= -golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/term v0.31.0 h1:erwDkOK1Msy6offm1mOgvspSkslFnIGsFnxOKoufg3o= -golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw= +golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= +golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg= +golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= From a5391274324728bfe9a5a08bb52c958d43601780 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 30 May 2025 10:04:39 -0300 Subject: [PATCH 165/198] ci: update lint jobs and settings --- .github/workflows/lint-soft.yml | 28 ---------------------- .github/workflows/lint-sync.yml | 14 +++++++++++ .github/workflows/lint.yml | 24 ++----------------- .golangci-soft.yml | 39 ------------------------------- .golangci.yml | 41 ++++++++++++++++++++++----------- 5 files changed, 43 insertions(+), 103 deletions(-) delete mode 100644 .github/workflows/lint-soft.yml create mode 100644 .github/workflows/lint-sync.yml delete mode 100644 .golangci-soft.yml diff --git a/.github/workflows/lint-soft.yml b/.github/workflows/lint-soft.yml deleted file mode 100644 index 1c760c4..0000000 --- a/.github/workflows/lint-soft.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: lint-soft -on: - push: - pull_request: - -permissions: - contents: read - # Optional: allow read access to pull request. Use with `only-new-issues` option. - pull-requests: read - -jobs: - golangci: - name: lint-soft - runs-on: ubuntu-latest - steps: - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: ^1 - - - uses: actions/checkout@v4 - - name: golangci-lint - uses: golangci/golangci-lint-action@v8 - with: - # Optional: golangci-lint command line arguments. - args: --config .golangci-soft.yml --issues-exit-code=0 - # Optional: show only new issues if it's a pull request. The default value is `false`. - only-new-issues: true diff --git a/.github/workflows/lint-sync.yml b/.github/workflows/lint-sync.yml new file mode 100644 index 0000000..ecf8580 --- /dev/null +++ b/.github/workflows/lint-sync.yml @@ -0,0 +1,14 @@ +name: lint-sync +on: + schedule: + # every Sunday at midnight + - cron: "0 0 * * 0" + workflow_dispatch: # allows manual triggering + +permissions: + contents: write + pull-requests: write + +jobs: + lint: + uses: charmbracelet/meta/.github/workflows/lint-sync.yml@main diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6d24b1a..a1d6d0e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -3,26 +3,6 @@ on: push: pull_request: -permissions: - contents: read - # Optional: allow read access to pull request. Use with `only-new-issues` option. - pull-requests: read - jobs: - golangci: - name: lint - runs-on: ubuntu-latest - steps: - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: ^1 - - - uses: actions/checkout@v4 - - name: golangci-lint - uses: golangci/golangci-lint-action@v8 - with: - # Optional: golangci-lint command line arguments. - #args: - # Optional: show only new issues if it's a pull request. The default value is `false`. - only-new-issues: true + lint: + uses: charmbracelet/meta/.github/workflows/lint.yml@main diff --git a/.golangci-soft.yml b/.golangci-soft.yml deleted file mode 100644 index 82c337e..0000000 --- a/.golangci-soft.yml +++ /dev/null @@ -1,39 +0,0 @@ -run: - tests: false - -issues: - include: - - EXC0001 - - EXC0005 - - EXC0011 - - EXC0012 - - EXC0013 - - max-issues-per-linter: 0 - max-same-issues: 0 - -linters: - enable: - - exhaustive - - goconst - - godot - - godox - - mnd - - gomoddirectives - - goprintffuncname - - misspell - - nakedret - - nestif - - noctx - - nolintlint - - prealloc - - # disable default linters, they are already enabled in .golangci.yml - disable: - - wrapcheck - - errcheck - - gosimple - - govet - - ineffassign - - staticcheck - - typecheck diff --git a/.golangci.yml b/.golangci.yml index 684d54b..be61d89 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,24 +1,23 @@ +version: "2" run: tests: false - -issues: - include: - - EXC0001 - - EXC0005 - - EXC0011 - - EXC0012 - - EXC0013 - - max-issues-per-linter: 0 - max-same-issues: 0 - linters: enable: - bodyclose - - goimports + - exhaustive + - goconst + - godot + - godox + - gomoddirectives + - goprintffuncname - gosec + - misspell + - nakedret + - nestif - nilerr - - predeclared + - noctx + - nolintlint + - prealloc - revive - rowserrcheck - sqlclosecheck @@ -26,3 +25,17 @@ linters: - unconvert - unparam - whitespace + - wrapcheck + exclusions: + generated: lax + presets: + - common-false-positives +issues: + max-issues-per-linter: 0 + max-same-issues: 0 +formatters: + enable: + - gofumpt + - goimports + exclusions: + generated: lax From 817c4bd446a522f8600c911c359c82191c728a64 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 30 May 2025 10:34:31 -0300 Subject: [PATCH 166/198] fix: lint issues (#909) * fix: some of the lint issues * fix: staticcheck --- choose/command.go | 2 +- completion/bash.go | 3 +++ cursor/cursor.go | 1 + file/command.go | 2 +- file/file.go | 2 +- filter/filter.go | 8 ++++---- internal/decode/align.go | 1 + internal/exit/exit.go | 5 ++--- internal/files/files.go | 2 +- internal/log/log.go | 8 -------- internal/stack/stack.go | 26 -------------------------- internal/stdin/stdin.go | 1 + internal/timeout/context.go | 1 + internal/utils/utils.go | 15 --------------- log/command.go | 5 +++-- log/options.go | 2 +- main.go | 1 + man/command.go | 1 + pager/pager.go | 2 +- pager/search.go | 17 ++++++++++++----- spin/pty.go | 4 ++-- style/spacing.go | 8 +++++--- version/command.go | 1 + 23 files changed, 44 insertions(+), 74 deletions(-) delete mode 100644 internal/log/log.go delete mode 100644 internal/stack/stack.go delete mode 100644 internal/utils/utils.go diff --git a/choose/command.go b/choose/command.go index 63194f0..8821258 100644 --- a/choose/command.go +++ b/choose/command.go @@ -38,7 +38,7 @@ func (o Options) Run() error { // normalize options into a map options := map[string]string{} // keep the labels in the user-provided order - var labels []string + var labels []string //nolint:prealloc for _, opt := range o.Options { if o.LabelDelimiter == "" { options[opt] = opt diff --git a/completion/bash.go b/completion/bash.go index 3064ec1..33d309b 100644 --- a/completion/bash.go +++ b/completion/bash.go @@ -1,3 +1,5 @@ +// Package completion provides a bash completion generator for Kong +// applications. package completion import ( @@ -628,6 +630,7 @@ func writeCmdAliases(buf io.StringWriter, cmd *kong.Node) { writeString(buf, ` fi`) writeString(buf, "\n") } + func writeArgAliases(buf io.StringWriter, cmd *kong.Node) { writeString(buf, " noun_aliases=()\n") sort.Strings(cmd.Aliases) diff --git a/cursor/cursor.go b/cursor/cursor.go index aa49c05..3c49849 100644 --- a/cursor/cursor.go +++ b/cursor/cursor.go @@ -1,3 +1,4 @@ +// Package cursor provides cursor modes. package cursor import ( diff --git a/file/command.go b/file/command.go index 89472dd..09b53c1 100644 --- a/file/command.go +++ b/file/command.go @@ -30,7 +30,7 @@ func (o Options) Run() error { fp := filepicker.New() fp.CurrentDirectory = path fp.Path = path - fp.Height = o.Height + fp.SetHeight(o.Height) fp.AutoHeight = o.Height == 0 fp.Cursor = o.Cursor fp.DirAllowed = o.Directory diff --git a/file/file.go b/file/file.go index a9878af..f7b142b 100644 --- a/file/file.go +++ b/file/file.go @@ -69,7 +69,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case tea.WindowSizeMsg: if m.showHelp { - m.filepicker.Height -= lipgloss.Height(m.helpView()) + m.filepicker.Height -= lipgloss.Height(m.helpView()) //nolint:staticcheck } case tea.KeyMsg: switch { diff --git a/filter/filter.go b/filter/filter.go index d321bcb..ef64c69 100644 --- a/filter/filter.go +++ b/filter/filter.go @@ -398,7 +398,7 @@ func (m *model) CursorUp() { if m.reverse { //nolint:nestif m.cursor = (m.cursor + 1) % len(m.matches) if len(m.matches)-m.cursor <= m.viewport.YOffset { - m.viewport.LineUp(1) + m.viewport.ScrollUp(1) } if len(m.matches)-m.cursor > m.viewport.Height+m.viewport.YOffset { m.viewport.SetYOffset(len(m.matches) - m.viewport.Height) @@ -406,7 +406,7 @@ func (m *model) CursorUp() { } else { m.cursor = (m.cursor - 1 + len(m.matches)) % len(m.matches) if m.cursor < m.viewport.YOffset { - m.viewport.LineUp(1) + m.viewport.ScrollUp(1) } if m.cursor >= m.viewport.YOffset+m.viewport.Height { m.viewport.SetYOffset(len(m.matches) - m.viewport.Height) @@ -421,7 +421,7 @@ func (m *model) CursorDown() { if m.reverse { //nolint:nestif m.cursor = (m.cursor - 1 + len(m.matches)) % len(m.matches) if len(m.matches)-m.cursor > m.viewport.Height+m.viewport.YOffset { - m.viewport.LineDown(1) + m.viewport.ScrollDown(1) } if len(m.matches)-m.cursor <= m.viewport.YOffset { m.viewport.GotoTop() @@ -429,7 +429,7 @@ func (m *model) CursorDown() { } else { m.cursor = (m.cursor + 1) % len(m.matches) if m.cursor >= m.viewport.YOffset+m.viewport.Height { - m.viewport.LineDown(1) + m.viewport.ScrollDown(1) } if m.cursor < m.viewport.YOffset { m.viewport.GotoTop() diff --git a/internal/decode/align.go b/internal/decode/align.go index 813bcdd..555f13c 100644 --- a/internal/decode/align.go +++ b/internal/decode/align.go @@ -1,3 +1,4 @@ +// Package decode position strings to lipgloss. package decode import "github.com/charmbracelet/lipgloss" diff --git a/internal/exit/exit.go b/internal/exit/exit.go index c4f3387..f523efc 100644 --- a/internal/exit/exit.go +++ b/internal/exit/exit.go @@ -1,8 +1,7 @@ +// Package exit code implementation. package exit -import ( - "strconv" -) +import "strconv" // StatusTimeout is the exit code for timed out commands. const StatusTimeout = 124 diff --git a/internal/files/files.go b/internal/files/files.go index 51e6950..d1cd19e 100644 --- a/internal/files/files.go +++ b/internal/files/files.go @@ -1,3 +1,4 @@ +// Package files handles files. package files import ( @@ -18,7 +19,6 @@ func List() []string { files = append(files, path) return nil }) - if err != nil { return []string{} } diff --git a/internal/log/log.go b/internal/log/log.go deleted file mode 100644 index 2a9f9a9..0000000 --- a/internal/log/log.go +++ /dev/null @@ -1,8 +0,0 @@ -package log - -import "fmt" - -// Error prints an error message to the user. -func Error(message string) { - fmt.Println("Error:", message) -} diff --git a/internal/stack/stack.go b/internal/stack/stack.go deleted file mode 100644 index b28fedb..0000000 --- a/internal/stack/stack.go +++ /dev/null @@ -1,26 +0,0 @@ -package stack - -// Stack is a stack interface for integers. -type Stack struct { - Push func(int) - Pop func() int - Length func() int -} - -// NewStack returns a new stack of integers. -func NewStack() Stack { - slice := make([]int, 0) - return Stack{ - Push: func(i int) { - slice = append(slice, i) - }, - Pop: func() int { - res := slice[len(slice)-1] - slice = slice[:len(slice)-1] - return res - }, - Length: func() int { - return len(slice) - }, - } -} diff --git a/internal/stdin/stdin.go b/internal/stdin/stdin.go index 42b0162..2efdcfd 100644 --- a/internal/stdin/stdin.go +++ b/internal/stdin/stdin.go @@ -1,3 +1,4 @@ +// Package stdin handles processing input from stdin. package stdin import ( diff --git a/internal/timeout/context.go b/internal/timeout/context.go index 99eaf34..ffd39e9 100644 --- a/internal/timeout/context.go +++ b/internal/timeout/context.go @@ -1,3 +1,4 @@ +// Package timeout handles context timeouts. package timeout import ( diff --git a/internal/utils/utils.go b/internal/utils/utils.go deleted file mode 100644 index 0e38598..0000000 --- a/internal/utils/utils.go +++ /dev/null @@ -1,15 +0,0 @@ -package utils - -import ( - "strings" - - "github.com/charmbracelet/lipgloss" -) - -// LipglossPadding calculates how much padding a string is given by a style. -func LipglossPadding(style lipgloss.Style) (int, int) { - render := style.Render(" ") - before := strings.Index(render, " ") - after := len(render) - len(" ") - before - return before, after -} diff --git a/log/command.go b/log/command.go index aff18cf..1240083 100644 --- a/log/command.go +++ b/log/command.go @@ -1,3 +1,4 @@ +// Package log the log command. package log import ( @@ -16,7 +17,7 @@ func (o Options) Run() error { l := log.New(os.Stderr) if o.File != "" { - f, err := os.OpenFile(o.File, os.O_CREATE|os.O_WRONLY|os.O_APPEND, os.ModePerm) + f, err := os.OpenFile(o.File, os.O_CREATE|os.O_WRONLY|os.O_APPEND, os.ModePerm) //nolint:gosec if err != nil { return fmt.Errorf("error opening file: %w", err) } @@ -31,7 +32,7 @@ func (o Options) Run() error { if o.MinLevel != "" { lvl, err := log.ParseLevel(o.MinLevel) if err != nil { - return err + return err //nolint:wrapcheck } l.SetLevel(lvl) } diff --git a/log/options.go b/log/options.go index 73fbcec..12949e3 100644 --- a/log/options.go +++ b/log/options.go @@ -18,7 +18,7 @@ type Options struct { MinLevel string `help:"Minimal level to show" default:"" env:"GUM_LOG_LEVEL"` - LevelStyle style.Styles `embed:"" prefix:"level." help:"The style of the level being used" set:"defaultBold=true" envprefix:"GUM_LOG_LEVEL_"` //nolint:staticcheck + LevelStyle style.Styles `embed:"" prefix:"level." help:"The style of the level being used" set:"defaultBold=true" envprefix:"GUM_LOG_LEVEL_"` TimeStyle style.Styles `embed:"" prefix:"time." help:"The style of the time" envprefix:"GUM_LOG_TIME_"` PrefixStyle style.Styles `embed:"" prefix:"prefix." help:"The style of the prefix" set:"defaultBold=true" set:"defaultFaint=true" envprefix:"GUM_LOG_PREFIX_"` //nolint:staticcheck MessageStyle style.Styles `embed:"" prefix:"message." help:"The style of the message" envprefix:"GUM_LOG_MESSAGE_"` diff --git a/main.go b/main.go index 18fa9f0..eec4c90 100644 --- a/main.go +++ b/main.go @@ -1,3 +1,4 @@ +// Package main is Gum: a tool for glamorous shell scripts. package main import ( diff --git a/man/command.go b/man/command.go index 1d83dab..22f5bec 100644 --- a/man/command.go +++ b/man/command.go @@ -1,3 +1,4 @@ +// Package man the man command. package man import ( diff --git a/pager/pager.go b/pager/pager.go index 6b38403..324a314 100644 --- a/pager/pager.go +++ b/pager/pager.go @@ -158,7 +158,7 @@ func (m *model) processText(msg tea.WindowSizeMsg) { text.WriteString("\n") } } else { - text.WriteString(textStyle.Render(line)) //nolint: gosec + text.WriteString(textStyle.Render(line)) text.WriteString("\n") } } diff --git a/pager/search.go b/pager/search.go index be59a53..134096c 100644 --- a/pager/search.go +++ b/pager/search.go @@ -6,7 +6,6 @@ import ( "strings" "github.com/charmbracelet/bubbles/textinput" - "github.com/charmbracelet/gum/internal/utils" "github.com/charmbracelet/lipgloss" "github.com/charmbracelet/x/ansi" ) @@ -52,7 +51,7 @@ func (s *search) Execute(m *model) { m.content = query.ReplaceAllString(m.content, m.matchStyle.Render("$1")) // Recompile the regex to match the an replace the highlights. - leftPad, _ := utils.LipglossPadding(m.matchStyle) + leftPad, _ := lipglossPadding(m.matchStyle) matchingString := regexp.QuoteMeta(m.matchStyle.Render()[:leftPad]) + s.query.String() + regexp.QuoteMeta(m.matchStyle.Render()[leftPad:]) s.query, err = regexp.Compile(matchingString) if err != nil { @@ -82,7 +81,7 @@ func (s *search) NextMatch(m *model) { return } - leftPad, rightPad := utils.LipglossPadding(m.matchStyle) + leftPad, rightPad := lipglossPadding(m.matchStyle) s.matchIndex = (s.matchIndex + 1) % len(allMatches) match := allMatches[s.matchIndex] lhs := m.content[:match[0]] @@ -125,7 +124,7 @@ func (s *search) PrevMatch(m *model) { s.matchIndex = len(allMatches) - 1 } - leftPad, rightPad := utils.LipglossPadding(m.matchStyle) + leftPad, rightPad := lipglossPadding(m.matchStyle) match := allMatches[s.matchIndex] lhs := m.content[:match[0]] rhs := m.content[match[0]:] @@ -159,10 +158,18 @@ func softWrapEm(str string, maxWidth int, softWrap bool) string { text.WriteString("\n") } } else { - text.WriteString(line) //nolint: gosec + text.WriteString(line) text.WriteString("\n") } } return text.String() } + +// lipglossPadding calculates how much padding a string is given by a style. +func lipglossPadding(style lipgloss.Style) (int, int) { + render := style.Render(" ") + before := strings.Index(render, " ") + after := len(render) - len(" ") - before + return before, after +} diff --git a/spin/pty.go b/spin/pty.go index 92dbe84..9562434 100644 --- a/spin/pty.go +++ b/spin/pty.go @@ -10,12 +10,12 @@ import ( func openPty(f *os.File) (pty xpty.Pty, err error) { width, height, err := term.GetSize(f.Fd()) if err != nil { - return nil, err + return nil, err //nolint:wrapcheck } pty, err = xpty.NewPty(width, height) if err != nil { - return nil, err + return nil, err //nolint:wrapcheck } return pty, nil diff --git a/style/spacing.go b/style/spacing.go index 6b3fe26..d7f1238 100644 --- a/style/spacing.go +++ b/style/spacing.go @@ -5,9 +5,11 @@ import ( "strings" ) -const minTokens = 1 -const halfTokens = 2 -const maxTokens = 4 +const ( + minTokens = 1 + halfTokens = 2 + maxTokens = 4 +) // parsePadding parses 1 - 4 integers from a string and returns them in a top, // right, bottom, left order for use in the lipgloss.Padding() method. diff --git a/version/command.go b/version/command.go index 5102b34..f90177d 100644 --- a/version/command.go +++ b/version/command.go @@ -1,3 +1,4 @@ +// Package version the version command. package version import ( From f1e274c05f1239d42bc4724a605adab3075fdf06 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 2 Jun 2025 08:52:04 -0300 Subject: [PATCH 167/198] ci: sync golangci-lint config (#911) Co-authored-by: caarlos0 <245435+caarlos0@users.noreply.github.com> --- .golangci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index be61d89..4fac29c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -7,7 +7,6 @@ linters: - exhaustive - goconst - godot - - godox - gomoddirectives - goprintffuncname - gosec From 181be44694299276d88880f8305a2faa805b99ad Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Jun 2025 09:50:07 +0000 Subject: [PATCH 168/198] chore(deps): bump golang.org/x/text from 0.25.0 to 0.26.0 (#915) Bumps [golang.org/x/text](https://github.com/golang/text) from 0.25.0 to 0.26.0. - [Release notes](https://github.com/golang/text/releases) - [Commits](https://github.com/golang/text/compare/v0.25.0...v0.26.0) --- updated-dependencies: - dependency-name: golang.org/x/text dependency-version: 0.26.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 12e81cd..62fb3ce 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/muesli/termenv v0.16.0 github.com/rivo/uniseg v0.4.7 github.com/sahilm/fuzzy v0.1.1 - golang.org/x/text v0.25.0 + golang.org/x/text v0.26.0 ) require ( @@ -55,7 +55,7 @@ require ( github.com/yuin/goldmark-emoji v1.0.5 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/net v0.40.0 // indirect - golang.org/x/sync v0.14.0 // indirect + golang.org/x/sync v0.15.0 // indirect golang.org/x/sys v0.33.0 // indirect golang.org/x/term v0.32.0 // indirect ) diff --git a/go.sum b/go.sum index 45024f1..8c1617a 100644 --- a/go.sum +++ b/go.sum @@ -114,15 +114,15 @@ golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0J golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= -golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= -golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8= +golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg= golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= -golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= -golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= +golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M= +golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 8081f74c4a5117f371954611366b4d4400ec8008 Mon Sep 17 00:00:00 2001 From: arithmeticmean <162291318+arithmeticmean@users.noreply.github.com> Date: Tue, 10 Jun 2025 22:56:28 +0530 Subject: [PATCH 169/198] fix: logic to handle interrupt before timeout in error checking (#918) - Reorder conditions to check ErrInterrupted before ErrProgramKilled - Prevents Ctrl+C from being incorrectly treated as timeout --- main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index eec4c90..a61916e 100644 --- a/main.go +++ b/main.go @@ -78,13 +78,13 @@ func main() { if errors.As(err, &ex) { os.Exit(int(ex)) } + if errors.Is(err, tea.ErrInterrupted) { + os.Exit(exit.StatusAborted) + } if errors.Is(err, tea.ErrProgramKilled) { fmt.Fprintln(os.Stderr, "timed out") os.Exit(exit.StatusTimeout) } - if errors.Is(err, tea.ErrInterrupted) { - os.Exit(exit.StatusAborted) - } fmt.Fprintln(os.Stderr, err) os.Exit(1) } From 0107dffd27d07caaebda4d2615b368db3bc295f7 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 10 Jun 2025 15:42:57 -0300 Subject: [PATCH 170/198] fix(filter): text input width is too small (#919) close #913 --- filter/filter.go | 1 + 1 file changed, 1 insertion(+) diff --git a/filter/filter.go b/filter/filter.go index ef64c69..176659a 100644 --- a/filter/filter.go +++ b/filter/filter.go @@ -280,6 +280,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.viewport.Height = m.viewport.Height - lipgloss.Height(m.helpView()) } m.viewport.Width = msg.Width + m.textinput.Width = msg.Width if m.reverse { m.viewport.YOffset = clamp(0, len(m.matches), len(m.matches)-m.viewport.Height) } From 3c972b0873ee0e9f20cb8a6c90fc79380f2ca36b Mon Sep 17 00:00:00 2001 From: bashbunni <15822994+bashbunni@users.noreply.github.com> Date: Wed, 11 Jun 2025 04:14:11 -0700 Subject: [PATCH 171/198] docs: add contributing guidelines (#920) --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index e3129f3..8534320 100644 --- a/README.md +++ b/README.md @@ -457,6 +457,12 @@ gum filter < $HISTFILE --height 20 alias please="gum input --password | sudo -nS" ``` +## Contributing + +See [contributing][contribute]. + +[contribute]: https://github.com/charmbracelet/gum/contribute + ## Feedback We’d love to hear your thoughts on this project. Feel free to drop us a note! From 501402cbbaf9e5a1b88055e5495228f107c0ed46 Mon Sep 17 00:00:00 2001 From: Sebastian Adamczyk Date: Sat, 14 Jun 2025 15:38:25 +0200 Subject: [PATCH 172/198] fix(choose): fix typo in environment variable `GUM_CCHOOSE_TIMEOUT` (#922) Co-authored-by: sadamczyk <13919759+sadamczyk@users.noreply.github.com> --- choose/options.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/choose/options.go b/choose/options.go index f956eb0..4af1744 100644 --- a/choose/options.go +++ b/choose/options.go @@ -15,7 +15,7 @@ type Options struct { Height int `help:"Height of the list" default:"10" env:"GUM_CHOOSE_HEIGHT"` Cursor string `help:"Prefix to show on item that corresponds to the cursor position" default:"> " env:"GUM_CHOOSE_CURSOR"` ShowHelp bool `help:"Show help keybinds" default:"true" negatable:"" env:"GUM_CHOOSE_SHOW_HELP"` - Timeout time.Duration `help:"Timeout until choose returns selected element" default:"0s" env:"GUM_CCHOOSE_TIMEOUT"` // including timeout command options [Timeout,...] + Timeout time.Duration `help:"Timeout until choose returns selected element" default:"0s" env:"GUM_CHOOSE_TIMEOUT"` // including timeout command options [Timeout,...] Header string `help:"Header value" default:"Choose:" env:"GUM_CHOOSE_HEADER"` CursorPrefix string `help:"Prefix to show on the cursor item (hidden if limit is 1)" default:"• " env:"GUM_CHOOSE_CURSOR_PREFIX"` SelectedPrefix string `help:"Prefix to show on selected items (hidden if limit is 1)" default:"✓ " env:"GUM_CHOOSE_SELECTED_PREFIX"` From a50a8033fab3552fe7a7f27c00d9b160c87c233e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Jun 2025 11:28:43 +0000 Subject: [PATCH 173/198] chore(deps): bump github.com/charmbracelet/x/ansi from 0.9.2 to 0.9.3 (#925) Bumps [github.com/charmbracelet/x/ansi](https://github.com/charmbracelet/x) from 0.9.2 to 0.9.3. - [Commits](https://github.com/charmbracelet/x/compare/ansi/v0.9.2...ansi/v0.9.3) --- updated-dependencies: - dependency-name: github.com/charmbracelet/x/ansi dependency-version: 0.9.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 62fb3ce..ee6da59 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/charmbracelet/glamour v0.10.0 github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 github.com/charmbracelet/log v0.4.2 - github.com/charmbracelet/x/ansi v0.9.2 + github.com/charmbracelet/x/ansi v0.9.3 github.com/charmbracelet/x/editor v0.1.0 github.com/charmbracelet/x/term v0.2.1 github.com/charmbracelet/x/xpty v0.1.2 diff --git a/go.sum b/go.sum index 8c1617a..96176e1 100644 --- a/go.sum +++ b/go.sum @@ -32,8 +32,8 @@ github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 h1:ZR7e0r github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834/go.mod h1:aKC/t2arECF6rNOnaKaVU6y4t4ZeHQzqfxedE/VkVhA= github.com/charmbracelet/log v0.4.2 h1:hYt8Qj6a8yLnvR+h7MwsJv/XvmBJXiueUcI3cIxsyig= github.com/charmbracelet/log v0.4.2/go.mod h1:qifHGX/tc7eluv2R6pWIpyHDDrrb/AG71Pf2ysQu5nw= -github.com/charmbracelet/x/ansi v0.9.2 h1:92AGsQmNTRMzuzHEYfCdjQeUzTrgE1vfO5/7fEVoXdY= -github.com/charmbracelet/x/ansi v0.9.2/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE= +github.com/charmbracelet/x/ansi v0.9.3 h1:BXt5DHS/MKF+LjuK4huWrC6NCvHtexww7dMayh6GXd0= +github.com/charmbracelet/x/ansi v0.9.3/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE= github.com/charmbracelet/x/cellbuf v0.0.13 h1:/KBBKHuVRbq1lYx5BzEHBAFBP8VcQzJejZ/IA3iR28k= github.com/charmbracelet/x/cellbuf v0.0.13/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs= github.com/charmbracelet/x/conpty v0.1.0 h1:4zc8KaIcbiL4mghEON8D72agYtSeIgq8FSThSPQIb+U= From 7a076dfed12eb86e56f2a25eaea0cceb4de26da7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Jun 2025 11:41:27 +0000 Subject: [PATCH 174/198] chore(deps): bump github.com/Masterminds/semver/v3 from 3.3.1 to 3.4.0 (#927) Bumps [github.com/Masterminds/semver/v3](https://github.com/Masterminds/semver) from 3.3.1 to 3.4.0. - [Release notes](https://github.com/Masterminds/semver/releases) - [Changelog](https://github.com/Masterminds/semver/blob/master/CHANGELOG.md) - [Commits](https://github.com/Masterminds/semver/compare/v3.3.1...v3.4.0) --- updated-dependencies: - dependency-name: github.com/Masterminds/semver/v3 dependency-version: 3.4.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ee6da59..29233a5 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.23.0 toolchain go1.24.1 require ( - github.com/Masterminds/semver/v3 v3.3.1 + github.com/Masterminds/semver/v3 v3.4.0 github.com/alecthomas/kong v1.11.0 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.21.0 diff --git a/go.sum b/go.sum index 96176e1..da0fb9f 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= -github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4= -github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= +github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0= +github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0= github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E= From 99397479f14ba82ecabd9ae564b897ba67e90112 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Jun 2025 11:44:58 +0000 Subject: [PATCH 175/198] chore(deps): bump github.com/alecthomas/kong from 1.11.0 to 1.12.0 (#928) Bumps [github.com/alecthomas/kong](https://github.com/alecthomas/kong) from 1.11.0 to 1.12.0. - [Commits](https://github.com/alecthomas/kong/compare/v1.11.0...v1.12.0) --- updated-dependencies: - dependency-name: github.com/alecthomas/kong dependency-version: 1.12.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 29233a5..eb53d3b 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ toolchain go1.24.1 require ( github.com/Masterminds/semver/v3 v3.4.0 - github.com/alecthomas/kong v1.11.0 + github.com/alecthomas/kong v1.12.0 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.21.0 github.com/charmbracelet/bubbletea v1.3.5 diff --git a/go.sum b/go.sum index da0fb9f..433c5ce 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8v github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E= github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I= -github.com/alecthomas/kong v1.11.0 h1:y++1gI7jf8O7G7l4LZo5ASFhrhJvzc+WgF/arranEmM= -github.com/alecthomas/kong v1.11.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= +github.com/alecthomas/kong v1.12.0 h1:oKd/0fHSdajj5PfGDd3ScvEvpVJf9mT2mb5r9xYadYM= +github.com/alecthomas/kong v1.12.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= github.com/alecthomas/mango-kong v0.1.0 h1:iFVfP1k1K4qpml3JUQmD5I8MCQYfIvsD9mRdrw7jJC4= github.com/alecthomas/mango-kong v0.1.0/go.mod h1:t+TYVdsONUolf/BwVcm+15eqcdAj15h4Qe9MMFAwwT4= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= From 269da200268f5465396facb56f42e6e99645a78b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Jul 2025 11:58:16 +0000 Subject: [PATCH 176/198] chore(deps): bump golang.org/x/text from 0.26.0 to 0.27.0 (#931) Bumps [golang.org/x/text](https://github.com/golang/text) from 0.26.0 to 0.27.0. - [Release notes](https://github.com/golang/text/releases) - [Commits](https://github.com/golang/text/compare/v0.26.0...v0.27.0) --- updated-dependencies: - dependency-name: golang.org/x/text dependency-version: 0.27.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index eb53d3b..91161b9 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/muesli/termenv v0.16.0 github.com/rivo/uniseg v0.4.7 github.com/sahilm/fuzzy v0.1.1 - golang.org/x/text v0.26.0 + golang.org/x/text v0.27.0 ) require ( @@ -55,7 +55,7 @@ require ( github.com/yuin/goldmark-emoji v1.0.5 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/net v0.40.0 // indirect - golang.org/x/sync v0.15.0 // indirect + golang.org/x/sync v0.16.0 // indirect golang.org/x/sys v0.33.0 // indirect golang.org/x/term v0.32.0 // indirect ) diff --git a/go.sum b/go.sum index 433c5ce..f2dea8b 100644 --- a/go.sum +++ b/go.sum @@ -114,15 +114,15 @@ golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0J golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= -golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8= -golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw= +golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg= golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= -golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M= -golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA= +golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= +golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 8537aa9de42707e3ec958b75e2d3c074414d6278 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Jul 2025 12:27:30 +0000 Subject: [PATCH 177/198] chore(deps): bump github.com/charmbracelet/bubbletea from 1.3.5 to 1.3.6 (#932) Bumps [github.com/charmbracelet/bubbletea](https://github.com/charmbracelet/bubbletea) from 1.3.5 to 1.3.6. - [Release notes](https://github.com/charmbracelet/bubbletea/releases) - [Changelog](https://github.com/charmbracelet/bubbletea/blob/main/.goreleaser.yml) - [Commits](https://github.com/charmbracelet/bubbletea/compare/v1.3.5...v1.3.6) --- updated-dependencies: - dependency-name: github.com/charmbracelet/bubbletea dependency-version: 1.3.6 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 91161b9..73092cd 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/alecthomas/kong v1.12.0 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.21.0 - github.com/charmbracelet/bubbletea v1.3.5 + github.com/charmbracelet/bubbletea v1.3.6 github.com/charmbracelet/glamour v0.10.0 github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 github.com/charmbracelet/log v0.4.2 diff --git a/go.sum b/go.sum index f2dea8b..698fe9d 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/charmbracelet/bubbles v0.21.0 h1:9TdC97SdRVg/1aaXNVWfFH3nnLAwOXr8Fn6u6mfQdFs= github.com/charmbracelet/bubbles v0.21.0/go.mod h1:HF+v6QUR4HkEpz62dx7ym2xc71/KBHg+zKwJtMw+qtg= -github.com/charmbracelet/bubbletea v1.3.5 h1:JAMNLTbqMOhSwoELIr0qyP4VidFq72/6E9j7HHmRKQc= -github.com/charmbracelet/bubbletea v1.3.5/go.mod h1:TkCnmH+aBd4LrXhXcqrKiYwRs7qyQx5rBgH5fVY3v54= +github.com/charmbracelet/bubbletea v1.3.6 h1:VkHIxPJQeDt0aFJIsVxw8BQdh/F/L2KKZGsK6et5taU= +github.com/charmbracelet/bubbletea v1.3.6/go.mod h1:oQD9VCRQFF8KplacJLo28/jofOI2ToOfGYeFgBBxHOc= github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs= github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk= github.com/charmbracelet/glamour v0.10.0 h1:MtZvfwsYCx8jEPFJm3rIBFIMZUfUJ765oX8V6kXldcY= From 7e0ca9c3358474ede5a9f8174918656fdc1aad8f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Aug 2025 12:38:56 +0000 Subject: [PATCH 178/198] chore(deps): bump github.com/alecthomas/kong from 1.12.0 to 1.12.1 (#940) Bumps [github.com/alecthomas/kong](https://github.com/alecthomas/kong) from 1.12.0 to 1.12.1. - [Commits](https://github.com/alecthomas/kong/compare/v1.12.0...v1.12.1) --- updated-dependencies: - dependency-name: github.com/alecthomas/kong dependency-version: 1.12.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 73092cd..c218050 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ toolchain go1.24.1 require ( github.com/Masterminds/semver/v3 v3.4.0 - github.com/alecthomas/kong v1.12.0 + github.com/alecthomas/kong v1.12.1 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.21.0 github.com/charmbracelet/bubbletea v1.3.6 diff --git a/go.sum b/go.sum index 698fe9d..f408302 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8v github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E= github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I= -github.com/alecthomas/kong v1.12.0 h1:oKd/0fHSdajj5PfGDd3ScvEvpVJf9mT2mb5r9xYadYM= -github.com/alecthomas/kong v1.12.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= +github.com/alecthomas/kong v1.12.1 h1:iq6aMJDcFYP9uFrLdsiZQ2ZMmcshduyGv4Pek0MQPW0= +github.com/alecthomas/kong v1.12.1/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= github.com/alecthomas/mango-kong v0.1.0 h1:iFVfP1k1K4qpml3JUQmD5I8MCQYfIvsD9mRdrw7jJC4= github.com/alecthomas/mango-kong v0.1.0/go.mod h1:t+TYVdsONUolf/BwVcm+15eqcdAj15h4Qe9MMFAwwT4= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= From 8c12c2a6a2025b349fce7ad045dbe68a76d23583 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 11 Aug 2025 14:21:37 +0200 Subject: [PATCH 179/198] ci: sync golangci-lint config (#946) Co-authored-by: caarlos0 <245435+caarlos0@users.noreply.github.com> --- .golangci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index 4fac29c..929cb0a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -26,6 +26,10 @@ linters: - whitespace - wrapcheck exclusions: + rules: + - text: '(slog|log)\.\w+' + linters: + - noctx generated: lax presets: - common-false-positives From 886f5132a544cb89cecccd0fae1a11449e0134be Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Aug 2025 13:27:29 +0000 Subject: [PATCH 180/198] chore(deps): bump github.com/charmbracelet/x/ansi from 0.9.3 to 0.10.1 (#947) Bumps [github.com/charmbracelet/x/ansi](https://github.com/charmbracelet/x) from 0.9.3 to 0.10.1. - [Commits](https://github.com/charmbracelet/x/compare/ansi/v0.9.3...ansi/v0.10.1) --- updated-dependencies: - dependency-name: github.com/charmbracelet/x/ansi dependency-version: 0.10.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index c218050..6746b81 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/charmbracelet/glamour v0.10.0 github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 github.com/charmbracelet/log v0.4.2 - github.com/charmbracelet/x/ansi v0.9.3 + github.com/charmbracelet/x/ansi v0.10.1 github.com/charmbracelet/x/editor v0.1.0 github.com/charmbracelet/x/term v0.2.1 github.com/charmbracelet/x/xpty v0.1.2 diff --git a/go.sum b/go.sum index f408302..7405e32 100644 --- a/go.sum +++ b/go.sum @@ -32,8 +32,8 @@ github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 h1:ZR7e0r github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834/go.mod h1:aKC/t2arECF6rNOnaKaVU6y4t4ZeHQzqfxedE/VkVhA= github.com/charmbracelet/log v0.4.2 h1:hYt8Qj6a8yLnvR+h7MwsJv/XvmBJXiueUcI3cIxsyig= github.com/charmbracelet/log v0.4.2/go.mod h1:qifHGX/tc7eluv2R6pWIpyHDDrrb/AG71Pf2ysQu5nw= -github.com/charmbracelet/x/ansi v0.9.3 h1:BXt5DHS/MKF+LjuK4huWrC6NCvHtexww7dMayh6GXd0= -github.com/charmbracelet/x/ansi v0.9.3/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE= +github.com/charmbracelet/x/ansi v0.10.1 h1:rL3Koar5XvX0pHGfovN03f5cxLbCF2YvLeyz7D2jVDQ= +github.com/charmbracelet/x/ansi v0.10.1/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE= github.com/charmbracelet/x/cellbuf v0.0.13 h1:/KBBKHuVRbq1lYx5BzEHBAFBP8VcQzJejZ/IA3iR28k= github.com/charmbracelet/x/cellbuf v0.0.13/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs= github.com/charmbracelet/x/conpty v0.1.0 h1:4zc8KaIcbiL4mghEON8D72agYtSeIgq8FSThSPQIb+U= From 9d610efaf91134a97cde37058bcf30232b9c2ca9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Aug 2025 13:28:39 +0000 Subject: [PATCH 181/198] chore(deps): bump golang.org/x/text from 0.27.0 to 0.28.0 (#948) Bumps [golang.org/x/text](https://github.com/golang/text) from 0.27.0 to 0.28.0. - [Release notes](https://github.com/golang/text/releases) - [Commits](https://github.com/golang/text/compare/v0.27.0...v0.28.0) --- updated-dependencies: - dependency-name: golang.org/x/text dependency-version: 0.28.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6746b81..a7530c0 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/muesli/termenv v0.16.0 github.com/rivo/uniseg v0.4.7 github.com/sahilm/fuzzy v0.1.1 - golang.org/x/text v0.27.0 + golang.org/x/text v0.28.0 ) require ( diff --git a/go.sum b/go.sum index 7405e32..70a52a1 100644 --- a/go.sum +++ b/go.sum @@ -122,7 +122,7 @@ golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg= golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= +golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng= +golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 50fff7815a29267e26042b1446a47d2af3eacdde Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Aug 2025 13:00:28 +0000 Subject: [PATCH 182/198] chore(deps): bump actions/checkout from 4 to 5 (#949) Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5be3fe8..e495821 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: go-version: ~1.21 - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Download Go modules run: go mod download From 09940da8c024f518d5820239e38e2edc20e2b431 Mon Sep 17 00:00:00 2001 From: Charm <124303983+charmcli@users.noreply.github.com> Date: Tue, 26 Aug 2025 13:03:49 -0300 Subject: [PATCH 183/198] ci: sync dependabot config (#956) --- .github/dependabot.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 63ed01f..271179a 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -13,6 +13,10 @@ updates: commit-message: prefix: "chore" include: "scope" + groups: + all: + patterns: + - "*" - package-ecosystem: "github-actions" directory: "/" @@ -26,6 +30,10 @@ updates: commit-message: prefix: "chore" include: "scope" + groups: + all: + patterns: + - "*" - package-ecosystem: "docker" directory: "/" @@ -39,3 +47,7 @@ updates: commit-message: prefix: "chore" include: "scope" + groups: + all: + patterns: + - "*" From 6045525ab92f75c169d3c69596844d8748437e37 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 5 Sep 2025 13:55:10 -0300 Subject: [PATCH 184/198] feat: adding --padding to most commands (#960) * feat(filter,choose): allow UI to be padded * feat: --padding everywhere Signed-off-by: Carlos Alexandro Becker * fix: unrelated lint issue Signed-off-by: Carlos Alexandro Becker * fix: filter Signed-off-by: Carlos Alexandro Becker * fix: use ordered.Clamp Signed-off-by: Carlos Alexandro Becker --------- Signed-off-by: Carlos Alexandro Becker Co-authored-by: Christian Rocha --- choose/choose.go | 21 +++++++----------- choose/command.go | 3 +++ choose/options.go | 1 + confirm/command.go | 3 +++ confirm/confirm.go | 26 ++++++++++++---------- confirm/options.go | 1 + file/command.go | 3 +++ file/file.go | 12 ++++++++-- file/options.go | 1 + filter/command.go | 4 +++- filter/filter.go | 55 +++++++++++++++++++++------------------------- filter/options.go | 1 + go.mod | 1 + go.sum | 2 ++ input/command.go | 3 +++ input/input.go | 26 ++++++++++++---------- input/options.go | 1 + spin/command.go | 3 +++ spin/options.go | 1 + spin/spin.go | 8 +++++-- style/lipgloss.go | 4 ++-- style/spacing.go | 6 ++--- table/command.go | 4 +++- table/options.go | 1 + table/table.go | 6 ++++- write/command.go | 7 ++++-- write/options.go | 1 + write/write.go | 10 +++++++-- 28 files changed, 133 insertions(+), 82 deletions(-) diff --git a/choose/choose.go b/choose/choose.go index 48f8857..c6be614 100644 --- a/choose/choose.go +++ b/choose/choose.go @@ -18,6 +18,7 @@ import ( "github.com/charmbracelet/bubbles/paginator" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/x/exp/ordered" ) func defaultKeymap() keymap { @@ -97,6 +98,7 @@ func (k keymap) ShortHelp() []key.Binding { type model struct { height int + padding []int cursor string selectedPrefix string unselectedPrefix string @@ -157,10 +159,10 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.paginator.PrevPage() } case key.Matches(msg, km.Right): - m.index = clamp(m.index+m.height, 0, len(m.items)-1) + m.index = ordered.Clamp(m.index+m.height, 0, len(m.items)-1) m.paginator.NextPage() case key.Matches(msg, km.Left): - m.index = clamp(m.index-m.height, 0, len(m.items)-1) + m.index = ordered.Clamp(m.index-m.height, 0, len(m.items)-1) m.paginator.PrevPage() case key.Matches(msg, km.End): m.index = len(m.items) - 1 @@ -280,15 +282,8 @@ func (m model) View() string { parts = append(parts, "", m.help.View(m.keymap)) } - return lipgloss.JoinVertical(lipgloss.Left, parts...) -} - -func clamp(x, low, high int) int { - if x < low { - return low - } - if x > high { - return high - } - return x + view := lipgloss.JoinVertical(lipgloss.Left, parts...) + return lipgloss.NewStyle(). + Padding(m.padding...). + Render(view) } diff --git a/choose/command.go b/choose/command.go index 8821258..70b8a9f 100644 --- a/choose/command.go +++ b/choose/command.go @@ -14,6 +14,7 @@ import ( "github.com/charmbracelet/gum/internal/stdin" "github.com/charmbracelet/gum/internal/timeout" "github.com/charmbracelet/gum/internal/tty" + "github.com/charmbracelet/gum/style" "github.com/charmbracelet/lipgloss" ) @@ -107,6 +108,7 @@ func (o Options) Run() error { // Use the pagination model to display the current and total number of // pages. + top, right, bottom, left := style.ParsePadding(o.Padding) pager := paginator.New() pager.SetTotalPages((len(items) + o.Height - 1) / o.Height) pager.PerPage = o.Height @@ -128,6 +130,7 @@ func (o Options) Run() error { index: startingIndex, currentOrder: currentOrder, height: o.Height, + padding: []int{top, right, bottom, left}, cursor: o.Cursor, header: o.Header, selectedPrefix: o.SelectedPrefix, diff --git a/choose/options.go b/choose/options.go index 4af1744..abfca22 100644 --- a/choose/options.go +++ b/choose/options.go @@ -26,6 +26,7 @@ type Options struct { OutputDelimiter string `help:"Option delimiter when writing to STDOUT" default:"\n" env:"GUM_CHOOSE_OUTPUT_DELIMITER"` LabelDelimiter string `help:"Allows to set a delimiter, so options can be set as label:value" default:"" env:"GUM_CHOOSE_LABEL_DELIMITER"` StripANSI bool `help:"Strip ANSI sequences when reading from STDIN" default:"true" negatable:"" env:"GUM_CHOOSE_STRIP_ANSI"` + Padding string `help:"Padding" default:"${defaultPadding}" group:"Style Flags" env:"GUM_CHOOSE_PADDING"` CursorStyle style.Styles `embed:"" prefix:"cursor." set:"defaultForeground=212" envprefix:"GUM_CHOOSE_CURSOR_"` HeaderStyle style.Styles `embed:"" prefix:"header." set:"defaultForeground=99" envprefix:"GUM_CHOOSE_HEADER_"` diff --git a/confirm/command.go b/confirm/command.go index e1f30bc..fc0a02b 100644 --- a/confirm/command.go +++ b/confirm/command.go @@ -10,6 +10,7 @@ import ( "github.com/charmbracelet/gum/internal/exit" "github.com/charmbracelet/gum/internal/stdin" "github.com/charmbracelet/gum/internal/timeout" + "github.com/charmbracelet/gum/style" ) // Run provides a shell script interface for prompting a user to confirm an @@ -28,6 +29,7 @@ func (o Options) Run() error { ctx, cancel := timeout.Context(o.Timeout) defer cancel() + top, right, bottom, left := style.ParsePadding(o.Padding) m := model{ affirmative: o.Affirmative, negative: o.Negative, @@ -41,6 +43,7 @@ func (o Options) Run() error { selectedStyle: o.SelectedStyle.ToLipgloss(), unselectedStyle: o.UnselectedStyle.ToLipgloss(), promptStyle: o.PromptStyle.ToLipgloss(), + padding: []int{top, right, bottom, left}, } tm, err := tea.NewProgram( m, diff --git a/confirm/confirm.go b/confirm/confirm.go index c32ade9..ac35c39 100644 --- a/confirm/confirm.go +++ b/confirm/confirm.go @@ -91,6 +91,7 @@ type model struct { promptStyle lipgloss.Style selectedStyle lipgloss.Style unselectedStyle lipgloss.Style + padding []int } func (m model) Init() tea.Cmd { return nil } @@ -149,18 +150,19 @@ func (m model) View() string { neg = "" } - if m.showHelp { - return lipgloss.JoinVertical( - lipgloss.Left, - m.promptStyle.Render(m.prompt)+"\n", - lipgloss.JoinHorizontal(lipgloss.Left, aff, neg), - "\n"+m.help.View(m.keys), - ) + parts := []string{ + m.promptStyle.Render(m.prompt) + "\n", + lipgloss.JoinHorizontal(lipgloss.Left, aff, neg), } - return lipgloss.JoinVertical( - lipgloss.Left, - m.promptStyle.Render(m.prompt)+"\n", - lipgloss.JoinHorizontal(lipgloss.Left, aff, neg), - ) + if m.showHelp { + parts = append(parts, "", m.help.View(m.keys)) + } + + return lipgloss.NewStyle(). + Padding(m.padding...). + Render(lipgloss.JoinVertical( + lipgloss.Left, + parts..., + )) } diff --git a/confirm/options.go b/confirm/options.go index b38d7e0..9740885 100644 --- a/confirm/options.go +++ b/confirm/options.go @@ -21,4 +21,5 @@ type Options struct { UnselectedStyle style.Styles `embed:"" prefix:"unselected." help:"The style of the unselected action" set:"defaultBackground=235" set:"defaultForeground=254" set:"defaultPadding=0 3" set:"defaultMargin=0 1" envprefix:"GUM_CONFIRM_UNSELECTED_"` ShowHelp bool `help:"Show help key binds" negatable:"" default:"true" env:"GUM_CONFIRM_SHOW_HELP"` Timeout time.Duration `help:"Timeout until confirm returns selected value or default if provided" default:"0s" env:"GUM_CONFIRM_TIMEOUT"` + Padding string `help:"Padding" default:"${defaultPadding}" group:"Style Flags" env:"GUM_CONFIRM_PADDING"` } diff --git a/file/command.go b/file/command.go index 09b53c1..b7cc546 100644 --- a/file/command.go +++ b/file/command.go @@ -10,6 +10,7 @@ import ( "github.com/charmbracelet/bubbles/help" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/gum/internal/timeout" + "github.com/charmbracelet/gum/style" ) // Run is the interface to picking a file. @@ -46,8 +47,10 @@ func (o Options) Run() error { fp.Styles.Permission = o.PermissionsStyle.ToLipgloss() fp.Styles.Selected = o.SelectedStyle.ToLipgloss() fp.Styles.FileSize = o.FileSizeStyle.ToLipgloss() + top, right, bottom, left := style.ParsePadding(o.Padding) m := model{ filepicker: fp, + padding: []int{top, right, bottom, left}, showHelp: o.ShowHelp, help: help.New(), keymap: defaultKeymap(), diff --git a/file/file.go b/file/file.go index f7b142b..33c8233 100644 --- a/file/file.go +++ b/file/file.go @@ -59,6 +59,7 @@ type model struct { selectedPath string quitting bool showHelp bool + padding []int help help.Model keymap keymap } @@ -68,9 +69,11 @@ func (m model) Init() tea.Cmd { return m.filepicker.Init() } func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case tea.WindowSizeMsg: + height := msg.Height - m.padding[0] - m.padding[2] if m.showHelp { - m.filepicker.Height -= lipgloss.Height(m.helpView()) //nolint:staticcheck + height -= lipgloss.Height(m.helpView()) } + m.filepicker.SetHeight(height) case tea.KeyMsg: switch { case key.Matches(msg, keyAbort): @@ -103,7 +106,12 @@ func (m model) View() string { if m.showHelp { parts = append(parts, m.helpView()) } - return lipgloss.JoinVertical(lipgloss.Left, parts...) + return lipgloss.NewStyle(). + Padding(m.padding...). + Render(lipgloss.JoinVertical( + lipgloss.Left, + parts..., + )) } func (m model) helpView() string { diff --git a/file/options.go b/file/options.go index 72bfb8f..61c9ced 100644 --- a/file/options.go +++ b/file/options.go @@ -30,4 +30,5 @@ type Options struct { SelectedStyle style.Styles `embed:"" prefix:"selected." help:"The style to use for the selected item" set:"defaultBold=true" set:"defaultForeground=212" envprefix:"GUM_FILE_SELECTED_"` //nolint:staticcheck FileSizeStyle style.Styles `embed:"" prefix:"file-size." help:"The style to use for file sizes" set:"defaultWidth=8" set:"defaultAlign=right" set:"defaultForeground=240" envprefix:"GUM_FILE_FILE_SIZE_"` //nolint:staticcheck HeaderStyle style.Styles `embed:"" prefix:"header." set:"defaultForeground=99" envprefix:"GUM_FILE_HEADER_"` + Padding string `help:"Padding" default:"${defaultPadding}" group:"Style Flags" env:"GUM_FILE_PADDING"` } diff --git a/filter/command.go b/filter/command.go index 4185100..6c9b2a3 100644 --- a/filter/command.go +++ b/filter/command.go @@ -15,6 +15,7 @@ import ( "github.com/charmbracelet/gum/internal/stdin" "github.com/charmbracelet/gum/internal/timeout" "github.com/charmbracelet/gum/internal/tty" + "github.com/charmbracelet/gum/style" "github.com/charmbracelet/x/ansi" "github.com/sahilm/fuzzy" ) @@ -94,7 +95,7 @@ func (o Options) Run() error { km.ToggleAndNext.SetEnabled(true) km.ToggleAll.SetEnabled(true) } - + top, right, bottom, left := style.ParsePadding(o.Padding) m := model{ choices: choices, filteringChoices: filteringChoices, @@ -113,6 +114,7 @@ func (o Options) Run() error { textStyle: o.TextStyle.ToLipgloss(), cursorTextStyle: o.CursorTextStyle.ToLipgloss(), height: o.Height, + padding: []int{top, right, bottom, left}, selected: make(map[string]struct{}), limit: o.Limit, reverse: o.Reverse, diff --git a/filter/filter.go b/filter/filter.go index 176659a..5e433cd 100644 --- a/filter/filter.go +++ b/filter/filter.go @@ -19,6 +19,7 @@ import ( "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/x/exp/ordered" "github.com/rivo/uniseg" "github.com/sahilm/fuzzy" ) @@ -137,6 +138,7 @@ type model struct { selectedPrefix string unselectedPrefix string height int + padding []int quitting bool headerStyle lipgloss.Style matchStyle lipgloss.Style @@ -230,33 +232,35 @@ func (m model) View() string { m.viewport.SetContent(s.String()) - help := "" - if m.showHelp { - help = m.helpView() - } - // View the input and the filtered choices header := m.headerStyle.Render(m.header) if m.reverse { - view := m.viewport.View() + "\n" + m.textinput.View() - if m.showHelp { - view += help - } + view := m.viewport.View() if m.header != "" { - return lipgloss.JoinVertical(lipgloss.Left, view, header) + view += "\n" + header } - - return view + view += "\n" + m.textinput.View() + if m.showHelp { + view += m.helpView() + } + return lipgloss.NewStyle(). + Padding(m.padding...). + Render(view) } view := m.textinput.View() + "\n" + m.viewport.View() if m.showHelp { - view += help + view += m.helpView() } if m.header != "" { - return lipgloss.JoinVertical(lipgloss.Left, header, view) + return lipgloss.NewStyle(). + Padding(m.padding...). + Render(header + "\n" + view) } - return view + + return lipgloss.NewStyle(). + Padding(m.padding...). + Render(view) } func (m model) helpView() string { @@ -279,10 +283,11 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if m.showHelp { m.viewport.Height = m.viewport.Height - lipgloss.Height(m.helpView()) } - m.viewport.Width = msg.Width - m.textinput.Width = msg.Width + m.viewport.Height = m.viewport.Height - m.padding[0] - m.padding[2] + m.viewport.Width = msg.Width - m.padding[1] - m.padding[3] + m.textinput.Width = msg.Width - m.padding[1] - m.padding[3] if m.reverse { - m.viewport.YOffset = clamp(0, len(m.matches), len(m.matches)-m.viewport.Height) + m.viewport.YOffset = ordered.Clamp(len(m.matches)-m.viewport.Height, 0, len(m.matches)) } case tea.KeyMsg: km := m.keymap @@ -374,7 +379,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { // it remains at a constant position relative to the cursor. if m.reverse { maxYOffset := max(0, len(m.matches)-m.viewport.Height) - m.viewport.YOffset = clamp(0, maxYOffset, len(m.matches)-yOffsetFromBottom) + m.viewport.YOffset = ordered.Clamp(len(m.matches)-yOffsetFromBottom, 0, maxYOffset) } } } @@ -388,7 +393,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { // It's possible that filtering items have caused fewer matches. So, ensure // that the selected index is within the bounds of the number of matches. - m.cursor = clamp(0, len(m.matches)-1, m.cursor) + m.cursor = ordered.Clamp(m.cursor, 0, len(m.matches)-1) return m, tea.Batch(cmd, icmd) } @@ -499,16 +504,6 @@ func exactMatches(search string, choices []string) []fuzzy.Match { return matches } -func clamp(low, high, val int) int { - if val < low { - return low - } - if val > high { - return high - } - return val -} - func matchedRanges(in []int) [][2]int { if len(in) == 0 { return [][2]int{} diff --git a/filter/options.go b/filter/options.go index e63644b..26eb3ea 100644 --- a/filter/options.go +++ b/filter/options.go @@ -41,6 +41,7 @@ type Options struct { InputDelimiter string `help:"Option delimiter when reading from STDIN" default:"\n" env:"GUM_FILTER_INPUT_DELIMITER"` OutputDelimiter string `help:"Option delimiter when writing to STDOUT" default:"\n" env:"GUM_FILTER_OUTPUT_DELIMITER"` StripANSI bool `help:"Strip ANSI sequences when reading from STDIN" default:"true" negatable:"" env:"GUM_FILTER_STRIP_ANSI"` + Padding string `help:"Padding" default:"${defaultPadding}" group:"Style Flags" env:"GUM_FILTER_PADDING"` // Deprecated: use [FuzzySort]. This will be removed at some point. Sort bool `help:"Sort fuzzy results by their scores" default:"true" env:"GUM_FILTER_FUZZY_SORT" negatable:"" hidden:""` diff --git a/go.mod b/go.mod index a7530c0..397fb65 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( github.com/charmbracelet/log v0.4.2 github.com/charmbracelet/x/ansi v0.10.1 github.com/charmbracelet/x/editor v0.1.0 + github.com/charmbracelet/x/exp/ordered v0.1.0 github.com/charmbracelet/x/term v0.2.1 github.com/charmbracelet/x/xpty v0.1.2 github.com/muesli/roff v0.1.0 diff --git a/go.sum b/go.sum index 70a52a1..d2db102 100644 --- a/go.sum +++ b/go.sum @@ -44,6 +44,8 @@ github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 h1:JSt3B+U9 github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86/go.mod h1:2P0UgXMEa6TsToMSuFqKFQR+fZTO9CNGUNokkPatT/0= github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 h1:payRxjMjKgx2PaCWLZ4p3ro9y97+TVLZNaRZgJwSVDQ= github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= +github.com/charmbracelet/x/exp/ordered v0.1.0 h1:55/qLwjIh0gL0Vni+QAWk7T/qRVP6sBf+2agPBgnOFE= +github.com/charmbracelet/x/exp/ordered v0.1.0/go.mod h1:5UHwmG+is5THxMyCJHNPCn2/ecI07aKNrW+LcResjJ8= github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf h1:rLG0Yb6MQSDKdB52aGX55JT1oi0P0Kuaj7wi1bLUpnI= github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf/go.mod h1:B3UgsnsBZS/eX42BlaNiJkD1pPOUa+oF1IYC6Yd2CEU= github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ= diff --git a/input/command.go b/input/command.go index 7d96e72..0900d8d 100644 --- a/input/command.go +++ b/input/command.go @@ -11,6 +11,7 @@ import ( "github.com/charmbracelet/gum/cursor" "github.com/charmbracelet/gum/internal/stdin" "github.com/charmbracelet/gum/internal/timeout" + "github.com/charmbracelet/gum/style" ) // Run provides a shell script interface for the text input bubble. @@ -43,10 +44,12 @@ func (o Options) Run() error { i.EchoCharacter = '•' } + top, right, bottom, left := style.ParsePadding(o.Padding) m := model{ textinput: i, header: o.Header, headerStyle: o.HeaderStyle.ToLipgloss(), + padding: []int{top, right, bottom, left}, autoWidth: o.Width < 1, showHelp: o.ShowHelp, help: help.New(), diff --git a/input/input.go b/input/input.go index 505b052..f63ac6a 100644 --- a/input/input.go +++ b/input/input.go @@ -38,6 +38,7 @@ func (k keymap) ShortHelp() []key.Binding { type model struct { autoWidth bool header string + padding []int headerStyle lipgloss.Style textinput textinput.Model quitting bool @@ -53,27 +54,30 @@ func (m model) View() string { if m.quitting { return "" } + var parts []string if m.header != "" { - header := m.headerStyle.Render(m.header) - return lipgloss.JoinVertical(lipgloss.Left, header, m.textinput.View()) + parts = append(parts, m.headerStyle.Render(m.header)) } - if !m.showHelp { - return m.textinput.View() + parts = append(parts, m.textinput.View()) + if m.showHelp { + parts = append(parts, "", m.help.View(m.keymap)) } - return lipgloss.JoinVertical( - lipgloss.Top, - m.textinput.View(), - "", - m.help.View(m.keymap), - ) + return lipgloss.NewStyle(). + Padding(m.padding...). + Render(lipgloss.JoinVertical( + lipgloss.Top, + parts..., + )) } func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case tea.WindowSizeMsg: if m.autoWidth { - m.textinput.Width = msg.Width - lipgloss.Width(m.textinput.Prompt) - 1 + m.textinput.Width = msg.Width - 1 - + lipgloss.Width(m.textinput.Prompt) - + m.padding[1] - m.padding[3] } case tea.KeyMsg: switch msg.String() { diff --git a/input/options.go b/input/options.go index 7463adb..57cbf53 100644 --- a/input/options.go +++ b/input/options.go @@ -23,4 +23,5 @@ type Options struct { HeaderStyle style.Styles `embed:"" prefix:"header." set:"defaultForeground=240" envprefix:"GUM_INPUT_HEADER_"` Timeout time.Duration `help:"Timeout until input aborts" default:"0s" env:"GUM_INPUT_TIMEOUT"` StripANSI bool `help:"Strip ANSI sequences when reading from STDIN" default:"true" negatable:"" env:"GUM_INPUT_STRIP_ANSI"` + Padding string `help:"Padding" default:"${defaultPadding}" group:"Style Flags" env:"GUM_INPUT_PADDING"` } diff --git a/spin/command.go b/spin/command.go index 08cb3bd..cff2797 100644 --- a/spin/command.go +++ b/spin/command.go @@ -8,6 +8,7 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/gum/internal/exit" "github.com/charmbracelet/gum/internal/timeout" + "github.com/charmbracelet/gum/style" "github.com/charmbracelet/x/term" ) @@ -20,6 +21,7 @@ func (o Options) Run() error { s := spinner.New() s.Style = o.SpinnerStyle.ToLipgloss() s.Spinner = spinnerMap[o.Spinner] + top, right, bottom, left := style.ParsePadding(o.Padding) m := model{ spinner: s, title: o.TitleStyle.ToLipgloss().Render(o.Title), @@ -29,6 +31,7 @@ func (o Options) Run() error { showStderr: (o.ShowOutput || o.ShowStderr) && isErrTTY, showError: o.ShowError, isTTY: isErrTTY, + padding: []int{top, right, bottom, left}, } ctx, cancel := timeout.Context(o.Timeout) diff --git a/spin/options.go b/spin/options.go index 5243eab..702cc2a 100644 --- a/spin/options.go +++ b/spin/options.go @@ -20,4 +20,5 @@ type Options struct { TitleStyle style.Styles `embed:"" prefix:"title." envprefix:"GUM_SPIN_TITLE_"` Align string `help:"Alignment of spinner with regard to the title" short:"a" type:"align" enum:"left,right" default:"left" env:"GUM_SPIN_ALIGN"` Timeout time.Duration `help:"Timeout until spin command aborts" default:"0s" env:"GUM_SPIN_TIMEOUT"` + Padding string `help:"Padding" default:"${defaultPadding}" group:"Style Flags" env:"GUM_SPIN_PADDING"` } diff --git a/spin/spin.go b/spin/spin.go index ee7ea7d..6e41690 100644 --- a/spin/spin.go +++ b/spin/spin.go @@ -25,6 +25,7 @@ import ( "github.com/charmbracelet/bubbles/spinner" tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/lipgloss" "github.com/charmbracelet/x/term" "github.com/charmbracelet/x/xpty" ) @@ -32,6 +33,7 @@ import ( type model struct { spinner spinner.Model title string + padding []int align string command []string quitting bool @@ -70,7 +72,7 @@ func commandStart(command []string) tea.Cmd { args = command[1:] } - executing = exec.Command(command[0], args...) //nolint:gosec + executing = exec.CommandContext(context.Background(), command[0], args...) //nolint:gosec executing.Stdin = os.Stdin isTerminal := term.IsTerminal(os.Stdout.Fd()) @@ -167,7 +169,9 @@ func (m model) View() string { } else { header = m.title + " " + m.spinner.View() } - return header + "\n" + out + return lipgloss.NewStyle(). + Padding(m.padding...). + Render(header, "", out) } func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { diff --git a/style/lipgloss.go b/style/lipgloss.go index 9ba52a2..07ad0c8 100644 --- a/style/lipgloss.go +++ b/style/lipgloss.go @@ -19,7 +19,7 @@ func (s Styles) ToLipgloss() lipgloss.Style { Height(s.Height). Width(s.Width). Margin(parseMargin(s.Margin)). - Padding(parsePadding(s.Padding)). + Padding(ParsePadding(s.Padding)). Bold(s.Bold). Faint(s.Faint). Italic(s.Italic). @@ -40,7 +40,7 @@ func (s StylesNotHidden) ToLipgloss() lipgloss.Style { Height(s.Height). Width(s.Width). Margin(parseMargin(s.Margin)). - Padding(parsePadding(s.Padding)). + Padding(ParsePadding(s.Padding)). Bold(s.Bold). Faint(s.Faint). Italic(s.Italic). diff --git a/style/spacing.go b/style/spacing.go index d7f1238..57ea7db 100644 --- a/style/spacing.go +++ b/style/spacing.go @@ -11,9 +11,9 @@ const ( maxTokens = 4 ) -// parsePadding parses 1 - 4 integers from a string and returns them in a top, +// ParsePadding parses 1 - 4 integers from a string and returns them in a top, // right, bottom, left order for use in the lipgloss.Padding() method. -func parsePadding(s string) (int, int, int, int) { +func ParsePadding(s string) (int, int, int, int) { var ints [maxTokens]int tokens := strings.Split(s, " ") @@ -48,4 +48,4 @@ func parsePadding(s string) (int, int, int, int) { // parseMargin is an alias for parsePadding since they involve the same logic // to parse integers to the same format. -var parseMargin = parsePadding +var parseMargin = ParsePadding diff --git a/table/command.go b/table/command.go index 4ee0fb9..479cd93 100644 --- a/table/command.go +++ b/table/command.go @@ -79,6 +79,7 @@ func (o Options) Run() error { } defaultStyles := table.DefaultStyles() + top, right, bottom, left := style.ParsePadding(o.Padding) styles := table.Styles{ Cell: defaultStyles.Cell.Inherit(o.CellStyle.ToLipgloss()), @@ -133,7 +134,7 @@ func (o Options) Run() error { table.WithStyles(styles), } if o.Height > 0 { - opts = append(opts, table.WithHeight(o.Height)) + opts = append(opts, table.WithHeight(o.Height-top-bottom)) } table := table.New(opts...) @@ -147,6 +148,7 @@ func (o Options) Run() error { hideCount: o.HideCount, help: help.New(), keymap: defaultKeymap(), + padding: []int{top, right, bottom, left}, } tm, err := tea.NewProgram( m, diff --git a/table/options.go b/table/options.go index 58efaa4..d7a241f 100644 --- a/table/options.go +++ b/table/options.go @@ -26,4 +26,5 @@ type Options struct { SelectedStyle style.Styles `embed:"" prefix:"selected." set:"defaultForeground=212" envprefix:"GUM_TABLE_SELECTED_"` ReturnColumn int `short:"r" help:"Which column number should be returned instead of whole row as string. Default=0 returns whole Row" default:"0"` Timeout time.Duration `help:"Timeout until choose returns selected element" default:"0s" env:"GUM_TABLE_TIMEOUT"` + Padding string `help:"Padding" default:"${defaultPadding}" group:"Style Flags" env:"GUM_TABLE_PADDING"` } diff --git a/table/table.go b/table/table.go index 9c6ed72..c0d389f 100644 --- a/table/table.go +++ b/table/table.go @@ -22,6 +22,7 @@ import ( "github.com/charmbracelet/bubbles/key" "github.com/charmbracelet/bubbles/table" tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/lipgloss" ) type keymap struct { @@ -72,6 +73,7 @@ type model struct { hideCount bool help help.Model keymap keymap + padding []int } func (m model) Init() tea.Cmd { return nil } @@ -122,7 +124,9 @@ func (m model) View() string { if m.showHelp { s += "\n" + m.countView() + m.help.View(m.keymap) } - return s + return lipgloss.NewStyle(). + Padding(m.padding...). + Render(s) } func numLen(i int) int { diff --git a/write/command.go b/write/command.go index adc3c69..6a745fb 100644 --- a/write/command.go +++ b/write/command.go @@ -12,6 +12,7 @@ import ( "github.com/charmbracelet/gum/cursor" "github.com/charmbracelet/gum/internal/stdin" "github.com/charmbracelet/gum/internal/timeout" + "github.com/charmbracelet/gum/style" ) // Run provides a shell script interface for the text area bubble. @@ -30,6 +31,7 @@ func (o Options) Run() error { a.ShowLineNumbers = o.ShowLineNumbers a.CharLimit = o.CharLimit a.MaxHeight = o.MaxLines + top, right, bottom, left := style.ParsePadding(o.Padding) style := textarea.Style{ Base: o.BaseStyle.ToLipgloss(), @@ -46,8 +48,8 @@ func (o Options) Run() error { a.Cursor.Style = o.CursorStyle.ToLipgloss() a.Cursor.SetMode(cursor.Modes[o.CursorMode]) - a.SetWidth(o.Width) - a.SetHeight(o.Height) + a.SetWidth(max(0, o.Width-left-right)) + a.SetHeight(max(0, o.Height-top-bottom)) a.SetValue(o.Value) m := model{ @@ -58,6 +60,7 @@ func (o Options) Run() error { help: help.New(), showHelp: o.ShowHelp, keymap: defaultKeymap(), + padding: []int{top, right, bottom, left}, } m.textarea.KeyMap.InsertNewline = m.keymap.InsertNewline diff --git a/write/options.go b/write/options.go index 16653eb..63c7b0c 100644 --- a/write/options.go +++ b/write/options.go @@ -32,4 +32,5 @@ type Options struct { HeaderStyle style.Styles `embed:"" prefix:"header." set:"defaultForeground=240" envprefix:"GUM_WRITE_HEADER_"` PlaceholderStyle style.Styles `embed:"" prefix:"placeholder." set:"defaultForeground=240" envprefix:"GUM_WRITE_PLACEHOLDER_"` PromptStyle style.Styles `embed:"" prefix:"prompt." set:"defaultForeground=7" envprefix:"GUM_WRITE_PROMPT_"` + Padding string `help:"Padding" default:"${defaultPadding}" group:"Style Flags" env:"GUM_WRITE_PADDING"` } diff --git a/write/write.go b/write/write.go index 323dc91..614ecaf 100644 --- a/write/write.go +++ b/write/write.go @@ -77,6 +77,7 @@ type model struct { showHelp bool help help.Model keymap keymap + padding []int } func (m model) Init() tea.Cmd { return textarea.Blink } @@ -96,14 +97,19 @@ func (m model) View() string { if m.showHelp { parts = append(parts, "", m.help.View(m.keymap)) } - return lipgloss.JoinVertical(lipgloss.Left, parts...) + return lipgloss.NewStyle(). + Padding(m.padding...). + Render(lipgloss.JoinVertical( + lipgloss.Left, + parts..., + )) } func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case tea.WindowSizeMsg: if m.autoWidth { - m.textarea.SetWidth(msg.Width) + m.textarea.SetWidth(msg.Width - m.padding[1] - m.padding[3]) } case tea.FocusMsg, tea.BlurMsg: var cmd tea.Cmd From e7ded305bc9f44b366c126302de6e4e6ba9df488 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Sep 2025 09:18:25 +0000 Subject: [PATCH 185/198] chore(deps): bump the all group with 2 updates (#962) Bumps the all group with 2 updates: [github.com/charmbracelet/bubbletea](https://github.com/charmbracelet/bubbletea) and [golang.org/x/text](https://github.com/golang/text). Updates `github.com/charmbracelet/bubbletea` from 1.3.6 to 1.3.7 - [Release notes](https://github.com/charmbracelet/bubbletea/releases) - [Changelog](https://github.com/charmbracelet/bubbletea/blob/main/.goreleaser.yml) - [Commits](https://github.com/charmbracelet/bubbletea/compare/v1.3.6...v1.3.7) Updates `golang.org/x/text` from 0.28.0 to 0.29.0 - [Release notes](https://github.com/golang/text/releases) - [Commits](https://github.com/golang/text/compare/v0.28.0...v0.29.0) --- updated-dependencies: - dependency-name: github.com/charmbracelet/bubbletea dependency-version: 1.3.7 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: all - dependency-name: golang.org/x/text dependency-version: 0.29.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 9 ++++----- go.sum | 14 ++++++-------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index 397fb65..1ad3fb6 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/charmbracelet/gum -go 1.23.0 +go 1.24.0 toolchain go1.24.1 @@ -9,7 +9,7 @@ require ( github.com/alecthomas/kong v1.12.1 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.21.0 - github.com/charmbracelet/bubbletea v1.3.6 + github.com/charmbracelet/bubbletea v1.3.7 github.com/charmbracelet/glamour v0.10.0 github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 github.com/charmbracelet/log v0.4.2 @@ -22,7 +22,7 @@ require ( github.com/muesli/termenv v0.16.0 github.com/rivo/uniseg v0.4.7 github.com/sahilm/fuzzy v0.1.1 - golang.org/x/text v0.28.0 + golang.org/x/text v0.29.0 ) require ( @@ -56,7 +56,6 @@ require ( github.com/yuin/goldmark-emoji v1.0.5 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/net v0.40.0 // indirect - golang.org/x/sync v0.16.0 // indirect - golang.org/x/sys v0.33.0 // indirect + golang.org/x/sys v0.34.0 // indirect golang.org/x/term v0.32.0 // indirect ) diff --git a/go.sum b/go.sum index d2db102..97a4491 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/charmbracelet/bubbles v0.21.0 h1:9TdC97SdRVg/1aaXNVWfFH3nnLAwOXr8Fn6u6mfQdFs= github.com/charmbracelet/bubbles v0.21.0/go.mod h1:HF+v6QUR4HkEpz62dx7ym2xc71/KBHg+zKwJtMw+qtg= -github.com/charmbracelet/bubbletea v1.3.6 h1:VkHIxPJQeDt0aFJIsVxw8BQdh/F/L2KKZGsK6et5taU= -github.com/charmbracelet/bubbletea v1.3.6/go.mod h1:oQD9VCRQFF8KplacJLo28/jofOI2ToOfGYeFgBBxHOc= +github.com/charmbracelet/bubbletea v1.3.7 h1:FNaEEFEenOEPnZsY9MI64thl2c84MI66+1QaQbxGOl4= +github.com/charmbracelet/bubbletea v1.3.7/go.mod h1:PEOcbQCNzJ2BYUd484kHPO5g3kLO28IffOdFeI2EWus= github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs= github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk= github.com/charmbracelet/glamour v0.10.0 h1:MtZvfwsYCx8jEPFJm3rIBFIMZUfUJ765oX8V6kXldcY= @@ -116,15 +116,13 @@ golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0J golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= -golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw= -golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= -golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= +golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg= golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= -golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng= -golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU= +golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= +golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 0e98776744b3ec26081abbc64bf7cfc88bbefd0f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Sep 2025 09:08:35 +0000 Subject: [PATCH 186/198] chore(deps): bump actions/setup-go from 5 to 6 in the all group Bumps the all group with 1 update: [actions/setup-go](https://github.com/actions/setup-go). Updates `actions/setup-go` from 5 to 6 - [Release notes](https://github.com/actions/setup-go/releases) - [Commits](https://github.com/actions/setup-go/compare/v5...v6) --- updated-dependencies: - dependency-name: actions/setup-go dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major dependency-group: all ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e495821..330d301 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: GO111MODULE: "on" steps: - name: Install Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: go-version: ~1.21 From 845f6b2ec8f4a8bf14b2d93db4c18d6689f08d58 Mon Sep 17 00:00:00 2001 From: Charm <124303983+charmcli@users.noreply.github.com> Date: Sun, 5 Oct 2025 12:30:53 -0300 Subject: [PATCH 187/198] ci: sync dependabot config (#973) --- .github/dependabot.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 271179a..d944991 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -17,6 +17,10 @@ updates: all: patterns: - "*" + ignore: + - dependency-name: github.com/charmbracelet/bubbletea/v2 + versions: + - v2.0.0-beta1 - package-ecosystem: "github-actions" directory: "/" From 4a5553eb21f4d422bbbe1d7a1a39265a6fa2257e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 5 Oct 2025 17:41:02 +0200 Subject: [PATCH 188/198] chore(deps): bump the all group across 1 directory with 3 updates (#974) Bumps the all group with 3 updates in the / directory: [github.com/charmbracelet/bubbletea](https://github.com/charmbracelet/bubbletea), [github.com/charmbracelet/x/ansi](https://github.com/charmbracelet/x) and [github.com/charmbracelet/x/xpty](https://github.com/charmbracelet/x). Updates `github.com/charmbracelet/bubbletea` from 1.3.7 to 1.3.10 - [Release notes](https://github.com/charmbracelet/bubbletea/releases) - [Changelog](https://github.com/charmbracelet/bubbletea/blob/main/.goreleaser.yml) - [Commits](https://github.com/charmbracelet/bubbletea/compare/v1.3.7...v1.3.10) Updates `github.com/charmbracelet/x/ansi` from 0.10.1 to 0.10.2 - [Commits](https://github.com/charmbracelet/x/compare/ansi/v0.10.1...ansi/v0.10.2) Updates `github.com/charmbracelet/x/xpty` from 0.1.2 to 0.1.3 - [Commits](https://github.com/charmbracelet/x/compare/ansi/v0.1.2...ansi/v0.1.3) --- updated-dependencies: - dependency-name: github.com/charmbracelet/bubbletea dependency-version: 1.3.10 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: all - dependency-name: github.com/charmbracelet/x/ansi dependency-version: 0.10.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: all - dependency-name: github.com/charmbracelet/x/xpty dependency-version: 0.1.3 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: all ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 14 +++++++------- go.sum | 28 ++++++++++++++-------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/go.mod b/go.mod index 1ad3fb6..2dcddb9 100644 --- a/go.mod +++ b/go.mod @@ -9,15 +9,15 @@ require ( github.com/alecthomas/kong v1.12.1 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.21.0 - github.com/charmbracelet/bubbletea v1.3.7 + github.com/charmbracelet/bubbletea v1.3.10 github.com/charmbracelet/glamour v0.10.0 github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 github.com/charmbracelet/log v0.4.2 - github.com/charmbracelet/x/ansi v0.10.1 + github.com/charmbracelet/x/ansi v0.10.2 github.com/charmbracelet/x/editor v0.1.0 github.com/charmbracelet/x/exp/ordered v0.1.0 github.com/charmbracelet/x/term v0.2.1 - github.com/charmbracelet/x/xpty v0.1.2 + github.com/charmbracelet/x/xpty v0.1.3 github.com/muesli/roff v0.1.0 github.com/muesli/termenv v0.16.0 github.com/rivo/uniseg v0.4.7 @@ -32,7 +32,7 @@ require ( github.com/aymerick/douceur v0.2.0 // indirect github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect github.com/charmbracelet/x/cellbuf v0.0.13 // indirect - github.com/charmbracelet/x/conpty v0.1.0 // indirect + github.com/charmbracelet/x/conpty v0.1.1 // indirect github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 // indirect github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf // indirect github.com/charmbracelet/x/termios v0.1.1 // indirect @@ -42,10 +42,10 @@ require ( github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/gorilla/css v1.0.1 // indirect - github.com/lucasb-eyer/go-colorful v1.2.0 // indirect + github.com/lucasb-eyer/go-colorful v1.3.0 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-localereader v0.0.1 // indirect - github.com/mattn/go-runewidth v0.0.16 // indirect + github.com/mattn/go-runewidth v0.0.17 // indirect github.com/microcosm-cc/bluemonday v1.0.27 // indirect github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect github.com/muesli/cancelreader v0.2.2 // indirect @@ -56,6 +56,6 @@ require ( github.com/yuin/goldmark-emoji v1.0.5 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/net v0.40.0 // indirect - golang.org/x/sys v0.34.0 // indirect + golang.org/x/sys v0.36.0 // indirect golang.org/x/term v0.32.0 // indirect ) diff --git a/go.sum b/go.sum index 97a4491..1984083 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/charmbracelet/bubbles v0.21.0 h1:9TdC97SdRVg/1aaXNVWfFH3nnLAwOXr8Fn6u6mfQdFs= github.com/charmbracelet/bubbles v0.21.0/go.mod h1:HF+v6QUR4HkEpz62dx7ym2xc71/KBHg+zKwJtMw+qtg= -github.com/charmbracelet/bubbletea v1.3.7 h1:FNaEEFEenOEPnZsY9MI64thl2c84MI66+1QaQbxGOl4= -github.com/charmbracelet/bubbletea v1.3.7/go.mod h1:PEOcbQCNzJ2BYUd484kHPO5g3kLO28IffOdFeI2EWus= +github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw= +github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4= github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs= github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk= github.com/charmbracelet/glamour v0.10.0 h1:MtZvfwsYCx8jEPFJm3rIBFIMZUfUJ765oX8V6kXldcY= @@ -32,12 +32,12 @@ github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 h1:ZR7e0r github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834/go.mod h1:aKC/t2arECF6rNOnaKaVU6y4t4ZeHQzqfxedE/VkVhA= github.com/charmbracelet/log v0.4.2 h1:hYt8Qj6a8yLnvR+h7MwsJv/XvmBJXiueUcI3cIxsyig= github.com/charmbracelet/log v0.4.2/go.mod h1:qifHGX/tc7eluv2R6pWIpyHDDrrb/AG71Pf2ysQu5nw= -github.com/charmbracelet/x/ansi v0.10.1 h1:rL3Koar5XvX0pHGfovN03f5cxLbCF2YvLeyz7D2jVDQ= -github.com/charmbracelet/x/ansi v0.10.1/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE= +github.com/charmbracelet/x/ansi v0.10.2 h1:ith2ArZS0CJG30cIUfID1LXN7ZFXRCww6RUvAPA+Pzw= +github.com/charmbracelet/x/ansi v0.10.2/go.mod h1:HbLdJjQH4UH4AqA2HpRWuWNluRE6zxJH/yteYEYCFa8= github.com/charmbracelet/x/cellbuf v0.0.13 h1:/KBBKHuVRbq1lYx5BzEHBAFBP8VcQzJejZ/IA3iR28k= github.com/charmbracelet/x/cellbuf v0.0.13/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs= -github.com/charmbracelet/x/conpty v0.1.0 h1:4zc8KaIcbiL4mghEON8D72agYtSeIgq8FSThSPQIb+U= -github.com/charmbracelet/x/conpty v0.1.0/go.mod h1:rMFsDJoDwVmiYM10aD4bH2XiRgwI7NYJtQgl5yskjEQ= +github.com/charmbracelet/x/conpty v0.1.1 h1:s1bUxjoi7EpqiXysVtC+a8RrvPPNcNvAjfi4jxsAuEs= +github.com/charmbracelet/x/conpty v0.1.1/go.mod h1:OmtR77VODEFbiTzGE9G1XiRJAga6011PIm4u5fTNZpk= github.com/charmbracelet/x/editor v0.1.0 h1:p69/dpvlwRTs9uYiPeAWruwsHqTFzHhTvQOd/WVSX98= github.com/charmbracelet/x/editor v0.1.0/go.mod h1:oivrEbcP/AYt/Hpvk5pwDXXrQ933gQS6UzL6fxqAGSA= github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 h1:JSt3B+U9iqk37QUU2Rvb6DSBYRLtWqFqfxf8l5hOZUA= @@ -52,8 +52,8 @@ github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQ github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg= github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8JawjaNZY= github.com/charmbracelet/x/termios v0.1.1/go.mod h1:rB7fnv1TgOPOyyKRJ9o+AsTU/vK5WHJ2ivHeut/Pcwo= -github.com/charmbracelet/x/xpty v0.1.2 h1:Pqmu4TEJ8KeA9uSkISKMU3f+C1F6OGBn8ABuGlqCbtI= -github.com/charmbracelet/x/xpty v0.1.2/go.mod h1:XK2Z0id5rtLWcpeNiMYBccNNBrP2IJnzHI0Lq13Xzq4= +github.com/charmbracelet/x/xpty v0.1.3 h1:eGSitii4suhzrISYH50ZfufV3v085BXQwIytcOdFSsw= +github.com/charmbracelet/x/xpty v0.1.3/go.mod h1:poPYpWuLDBFCKmKLDnhBp51ATa0ooD8FhypRwEFtH3Y= github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s= github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -72,15 +72,15 @@ github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUq github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= -github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= +github.com/lucasb-eyer/go-colorful v1.3.0 h1:2/yBRLdWBZKrf7gB40FoiKfAWYQ0lqNcbuQwVHXptag= +github.com/lucasb-eyer/go-colorful v1.3.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4= github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88= github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= -github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= -github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.17 h1:78v8ZlW0bP43XfmAfPsdXcoNCelfMHsDmd/pkENfrjQ= +github.com/mattn/go-runewidth v0.0.17/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk= github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA= github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI= @@ -118,8 +118,8 @@ golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= -golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k= +golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg= golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= From 0ad76ee88ccdadbde9fad4b1e35ae706426ec535 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 6 Dec 2025 21:17:45 -0300 Subject: [PATCH 189/198] ci: sync golangci-lint config (#995) Co-authored-by: caarlos0 <245435+caarlos0@users.noreply.github.com> --- .golangci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index 929cb0a..c90f031 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -33,6 +33,9 @@ linters: generated: lax presets: - common-false-positives + settings: + exhaustive: + default-signifies-exhaustive: true issues: max-issues-per-linter: 0 max-same-issues: 0 From 7871625c9d2e537a9a1dc85cb0879f351b804ec8 Mon Sep 17 00:00:00 2001 From: Jens Petersen Date: Wed, 21 Jan 2026 21:52:02 +0800 Subject: [PATCH 190/198] readme: gum is packaged in Fedora for some time (#1007) --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 8534320..9c66554 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,9 @@ brew install gum # Arch Linux (btw) pacman -S gum +# Fedora or EPEL 10 +dnf install gum + # Nix nix-env -iA nixpkgs.gum From f3a3f53026429fcde12b20b3ad707afd8b51b6eb Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Wed, 21 Jan 2026 11:04:33 -0300 Subject: [PATCH 191/198] ci: fix build action --- .github/workflows/build.yml | 54 +++++-------------------------------- 1 file changed, 7 insertions(+), 47 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 330d301..2330819 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,53 +1,13 @@ name: build -on: [push, pull_request] +on: + push: + branches: + - main + pull_request: jobs: build: - strategy: - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - runs-on: ${{ matrix.os }} - env: - GO111MODULE: "on" - steps: - - name: Install Go - uses: actions/setup-go@v6 - with: - go-version: ~1.21 - - - name: Checkout code - uses: actions/checkout@v5 - - - name: Download Go modules - run: go mod download - - - name: Build - run: go build -v ./... - - - name: Test - run: go test -v -cover -timeout=30s ./... - - snapshot: - uses: charmbracelet/meta/.github/workflows/snapshot.yml@main + uses: charmbracelet/meta/.github/workflows/build.yml@main secrets: - goreleaser_key: ${{ secrets.GORELEASER_KEY }} - - dependabot: - needs: [build] - runs-on: ubuntu-latest - permissions: - pull-requests: write - contents: write - if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request'}} - steps: - - id: metadata - uses: dependabot/fetch-metadata@v2 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - run: | - gh pr review --approve "$PR_URL" - gh pr merge --squash --auto "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + gh_pat: ${{ secrets.PERSONAL_ACCESS_TOKEN }} From 8502bbd80801069948b614e0fa55284aa46bff01 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Wed, 21 Jan 2026 11:08:16 -0300 Subject: [PATCH 192/198] chore: remove issue templates, inherit from `.github` repo The base ones should be used from now on: https://github.com/charmbracelet/.github/tree/main/.github/ISSUE_TEMPLATE --- .github/ISSUE_TEMPLATE/bug_report.md | 38 ----------------------- .github/ISSUE_TEMPLATE/feature_request.md | 20 ------------ 2 files changed, 58 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index dd84ea7..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Desktop (please complete the following information):** - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - Version [e.g. 22] - -**Smartphone (please complete the following information):** - - Device: [e.g. iPhone6] - - OS: [e.g. iOS8.1] - - Browser [e.g. stock browser, safari] - - Version [e.g. 22] - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index bbcbbe7..0000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: '' -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. From 7fafddf384faf52f3e251b4ed833766c52fe3a49 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Wed, 21 Jan 2026 09:36:40 -0500 Subject: [PATCH 193/198] chore: bump dependencies Fixes: https://github.com/charmbracelet/gum/pull/1004 --- go.mod | 19 ++++++++++--------- go.sum | 30 ++++++++++++++++++------------ 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/go.mod b/go.mod index 2dcddb9..28eb04d 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module github.com/charmbracelet/gum -go 1.24.0 - -toolchain go1.24.1 +go 1.24.2 require ( github.com/Masterminds/semver/v3 v3.4.0 @@ -13,10 +11,10 @@ require ( github.com/charmbracelet/glamour v0.10.0 github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 github.com/charmbracelet/log v0.4.2 - github.com/charmbracelet/x/ansi v0.10.2 + github.com/charmbracelet/x/ansi v0.11.4 github.com/charmbracelet/x/editor v0.1.0 github.com/charmbracelet/x/exp/ordered v0.1.0 - github.com/charmbracelet/x/term v0.2.1 + github.com/charmbracelet/x/term v0.2.2 github.com/charmbracelet/x/xpty v0.1.3 github.com/muesli/roff v0.1.0 github.com/muesli/termenv v0.16.0 @@ -30,12 +28,15 @@ require ( github.com/atotto/clipboard v0.1.4 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymerick/douceur v0.2.0 // indirect - github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect - github.com/charmbracelet/x/cellbuf v0.0.13 // indirect + github.com/charmbracelet/colorprofile v0.4.1 // indirect + github.com/charmbracelet/x/cellbuf v0.0.14 // indirect github.com/charmbracelet/x/conpty v0.1.1 // indirect github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 // indirect github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf // indirect github.com/charmbracelet/x/termios v0.1.1 // indirect + github.com/clipperhouse/displaywidth v0.7.0 // indirect + github.com/clipperhouse/stringish v0.1.1 // indirect + github.com/clipperhouse/uax29/v2 v2.3.1 // indirect github.com/creack/pty v1.1.24 // indirect github.com/dlclark/regexp2 v1.11.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect @@ -45,7 +46,7 @@ require ( github.com/lucasb-eyer/go-colorful v1.3.0 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-localereader v0.0.1 // indirect - github.com/mattn/go-runewidth v0.0.17 // indirect + github.com/mattn/go-runewidth v0.0.19 // indirect github.com/microcosm-cc/bluemonday v1.0.27 // indirect github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect github.com/muesli/cancelreader v0.2.2 // indirect @@ -56,6 +57,6 @@ require ( github.com/yuin/goldmark-emoji v1.0.5 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/net v0.40.0 // indirect - golang.org/x/sys v0.36.0 // indirect + golang.org/x/sys v0.38.0 // indirect golang.org/x/term v0.32.0 // indirect ) diff --git a/go.sum b/go.sum index 1984083..99ffdcb 100644 --- a/go.sum +++ b/go.sum @@ -24,18 +24,18 @@ github.com/charmbracelet/bubbles v0.21.0 h1:9TdC97SdRVg/1aaXNVWfFH3nnLAwOXr8Fn6u github.com/charmbracelet/bubbles v0.21.0/go.mod h1:HF+v6QUR4HkEpz62dx7ym2xc71/KBHg+zKwJtMw+qtg= github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw= github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4= -github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs= -github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk= +github.com/charmbracelet/colorprofile v0.4.1 h1:a1lO03qTrSIRaK8c3JRxJDZOvhvIeSco3ej+ngLk1kk= +github.com/charmbracelet/colorprofile v0.4.1/go.mod h1:U1d9Dljmdf9DLegaJ0nGZNJvoXAhayhmidOdcBwAvKk= github.com/charmbracelet/glamour v0.10.0 h1:MtZvfwsYCx8jEPFJm3rIBFIMZUfUJ765oX8V6kXldcY= github.com/charmbracelet/glamour v0.10.0/go.mod h1:f+uf+I/ChNmqo087elLnVdCiVgjSKWuXa/l6NU2ndYk= github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 h1:ZR7e0ro+SZZiIZD7msJyA+NjkCNNavuiPBLgerbOziE= github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834/go.mod h1:aKC/t2arECF6rNOnaKaVU6y4t4ZeHQzqfxedE/VkVhA= github.com/charmbracelet/log v0.4.2 h1:hYt8Qj6a8yLnvR+h7MwsJv/XvmBJXiueUcI3cIxsyig= github.com/charmbracelet/log v0.4.2/go.mod h1:qifHGX/tc7eluv2R6pWIpyHDDrrb/AG71Pf2ysQu5nw= -github.com/charmbracelet/x/ansi v0.10.2 h1:ith2ArZS0CJG30cIUfID1LXN7ZFXRCww6RUvAPA+Pzw= -github.com/charmbracelet/x/ansi v0.10.2/go.mod h1:HbLdJjQH4UH4AqA2HpRWuWNluRE6zxJH/yteYEYCFa8= -github.com/charmbracelet/x/cellbuf v0.0.13 h1:/KBBKHuVRbq1lYx5BzEHBAFBP8VcQzJejZ/IA3iR28k= -github.com/charmbracelet/x/cellbuf v0.0.13/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs= +github.com/charmbracelet/x/ansi v0.11.4 h1:6G65PLu6HjmE858CnTUQY1LXT3ZUWwfvqEROLF8vqHI= +github.com/charmbracelet/x/ansi v0.11.4/go.mod h1:/5AZ+UfWExW3int5H5ugnsG/PWjNcSQcwYsHBlPFQN4= +github.com/charmbracelet/x/cellbuf v0.0.14 h1:iUEMryGyFTelKW3THW4+FfPgi4fkmKnnaLOXuc+/Kj4= +github.com/charmbracelet/x/cellbuf v0.0.14/go.mod h1:P447lJl49ywBbil/KjCk2HexGh4tEY9LH0/1QrZZ9rA= github.com/charmbracelet/x/conpty v0.1.1 h1:s1bUxjoi7EpqiXysVtC+a8RrvPPNcNvAjfi4jxsAuEs= github.com/charmbracelet/x/conpty v0.1.1/go.mod h1:OmtR77VODEFbiTzGE9G1XiRJAga6011PIm4u5fTNZpk= github.com/charmbracelet/x/editor v0.1.0 h1:p69/dpvlwRTs9uYiPeAWruwsHqTFzHhTvQOd/WVSX98= @@ -48,12 +48,18 @@ github.com/charmbracelet/x/exp/ordered v0.1.0 h1:55/qLwjIh0gL0Vni+QAWk7T/qRVP6sB github.com/charmbracelet/x/exp/ordered v0.1.0/go.mod h1:5UHwmG+is5THxMyCJHNPCn2/ecI07aKNrW+LcResjJ8= github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf h1:rLG0Yb6MQSDKdB52aGX55JT1oi0P0Kuaj7wi1bLUpnI= github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf/go.mod h1:B3UgsnsBZS/eX42BlaNiJkD1pPOUa+oF1IYC6Yd2CEU= -github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ= -github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg= +github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk= +github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI= github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8JawjaNZY= github.com/charmbracelet/x/termios v0.1.1/go.mod h1:rB7fnv1TgOPOyyKRJ9o+AsTU/vK5WHJ2ivHeut/Pcwo= github.com/charmbracelet/x/xpty v0.1.3 h1:eGSitii4suhzrISYH50ZfufV3v085BXQwIytcOdFSsw= github.com/charmbracelet/x/xpty v0.1.3/go.mod h1:poPYpWuLDBFCKmKLDnhBp51ATa0ooD8FhypRwEFtH3Y= +github.com/clipperhouse/displaywidth v0.7.0 h1:QNv1GYsnLX9QBrcWUtMlogpTXuM5FVnBwKWp1O5NwmE= +github.com/clipperhouse/displaywidth v0.7.0/go.mod h1:R+kHuzaYWFkTm7xoMmK1lFydbci4X2CicfbGstSGg0o= +github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs= +github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA= +github.com/clipperhouse/uax29/v2 v2.3.1 h1:RjM8gnVbFbgI67SBekIC7ihFpyXwRPYWXn9BZActHbw= +github.com/clipperhouse/uax29/v2 v2.3.1/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g= github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s= github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -79,8 +85,8 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4= github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88= github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= -github.com/mattn/go-runewidth v0.0.17 h1:78v8ZlW0bP43XfmAfPsdXcoNCelfMHsDmd/pkENfrjQ= -github.com/mattn/go-runewidth v0.0.17/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw= +github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs= github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk= github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA= github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI= @@ -118,8 +124,8 @@ golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k= -golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= +golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg= golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= From dfe61991ceb1cab97f9b2ba2de04e6000c094c63 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Jan 2026 14:44:03 +0000 Subject: [PATCH 194/198] chore(deps): bump the all group with 3 updates Bumps the all group with 3 updates: [github.com/alecthomas/kong](https://github.com/alecthomas/kong), [github.com/charmbracelet/x/editor](https://github.com/charmbracelet/x) and [golang.org/x/text](https://github.com/golang/text). Updates `github.com/alecthomas/kong` from 1.12.1 to 1.13.0 - [Commits](https://github.com/alecthomas/kong/compare/v1.12.1...v1.13.0) Updates `github.com/charmbracelet/x/editor` from 0.1.0 to 0.2.0 - [Commits](https://github.com/charmbracelet/x/compare/v0.1.0...ansi/v0.2.0) Updates `golang.org/x/text` from 0.29.0 to 0.33.0 - [Release notes](https://github.com/golang/text/releases) - [Commits](https://github.com/golang/text/compare/v0.29.0...v0.33.0) --- updated-dependencies: - dependency-name: github.com/alecthomas/kong dependency-version: 1.13.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all - dependency-name: github.com/charmbracelet/x/editor dependency-version: 0.2.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all - dependency-name: golang.org/x/text dependency-version: 0.33.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all ... Signed-off-by: dependabot[bot] --- go.mod | 6 +++--- go.sum | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 28eb04d..a0622c6 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.24.2 require ( github.com/Masterminds/semver/v3 v3.4.0 - github.com/alecthomas/kong v1.12.1 + github.com/alecthomas/kong v1.13.0 github.com/alecthomas/mango-kong v0.1.0 github.com/charmbracelet/bubbles v0.21.0 github.com/charmbracelet/bubbletea v1.3.10 @@ -12,7 +12,7 @@ require ( github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 github.com/charmbracelet/log v0.4.2 github.com/charmbracelet/x/ansi v0.11.4 - github.com/charmbracelet/x/editor v0.1.0 + github.com/charmbracelet/x/editor v0.2.0 github.com/charmbracelet/x/exp/ordered v0.1.0 github.com/charmbracelet/x/term v0.2.2 github.com/charmbracelet/x/xpty v0.1.3 @@ -20,7 +20,7 @@ require ( github.com/muesli/termenv v0.16.0 github.com/rivo/uniseg v0.4.7 github.com/sahilm/fuzzy v0.1.1 - golang.org/x/text v0.29.0 + golang.org/x/text v0.33.0 ) require ( diff --git a/go.sum b/go.sum index 99ffdcb..85acb98 100644 --- a/go.sum +++ b/go.sum @@ -6,12 +6,12 @@ github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8v github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E= github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I= -github.com/alecthomas/kong v1.12.1 h1:iq6aMJDcFYP9uFrLdsiZQ2ZMmcshduyGv4Pek0MQPW0= -github.com/alecthomas/kong v1.12.1/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= +github.com/alecthomas/kong v1.13.0 h1:5e/7XC3ugvhP1DQBmTS+WuHtCbcv44hsohMgcvVxSrA= +github.com/alecthomas/kong v1.13.0/go.mod h1:wrlbXem1CWqUV5Vbmss5ISYhsVPkBb1Yo7YKJghju2I= github.com/alecthomas/mango-kong v0.1.0 h1:iFVfP1k1K4qpml3JUQmD5I8MCQYfIvsD9mRdrw7jJC4= github.com/alecthomas/mango-kong v0.1.0/go.mod h1:t+TYVdsONUolf/BwVcm+15eqcdAj15h4Qe9MMFAwwT4= -github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= -github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= +github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs= +github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= @@ -38,8 +38,8 @@ github.com/charmbracelet/x/cellbuf v0.0.14 h1:iUEMryGyFTelKW3THW4+FfPgi4fkmKnnaL github.com/charmbracelet/x/cellbuf v0.0.14/go.mod h1:P447lJl49ywBbil/KjCk2HexGh4tEY9LH0/1QrZZ9rA= github.com/charmbracelet/x/conpty v0.1.1 h1:s1bUxjoi7EpqiXysVtC+a8RrvPPNcNvAjfi4jxsAuEs= github.com/charmbracelet/x/conpty v0.1.1/go.mod h1:OmtR77VODEFbiTzGE9G1XiRJAga6011PIm4u5fTNZpk= -github.com/charmbracelet/x/editor v0.1.0 h1:p69/dpvlwRTs9uYiPeAWruwsHqTFzHhTvQOd/WVSX98= -github.com/charmbracelet/x/editor v0.1.0/go.mod h1:oivrEbcP/AYt/Hpvk5pwDXXrQ933gQS6UzL6fxqAGSA= +github.com/charmbracelet/x/editor v0.2.0 h1:7XLUKtaRaB8jN7bWU2p2UChiySyaAuIfYiIRg8gGWwk= +github.com/charmbracelet/x/editor v0.2.0/go.mod h1:p3oQ28TSL3YPd+GKJ1fHWcp+7bVGpedHpXmo0D6t1dY= github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 h1:JSt3B+U9iqk37QUU2Rvb6DSBYRLtWqFqfxf8l5hOZUA= github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86/go.mod h1:2P0UgXMEa6TsToMSuFqKFQR+fZTO9CNGUNokkPatT/0= github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 h1:payRxjMjKgx2PaCWLZ4p3ro9y97+TVLZNaRZgJwSVDQ= @@ -128,7 +128,7 @@ golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg= golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= -golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= -golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4= +golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE= +golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 057099caf0e53d6aa493278da1d009b86b62ccf7 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Wed, 21 Jan 2026 11:50:14 -0300 Subject: [PATCH 195/198] fix: write was not compiling --- write/write.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/write/write.go b/write/write.go index 614ecaf..b7e65a3 100644 --- a/write/write.go +++ b/write/write.go @@ -137,8 +137,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.submitted = true return m, tea.Quit case key.Matches(msg, km.OpenInEditor): - //nolint: gosec - return m, createTempFile(m.textarea.Value(), uint(m.textarea.Line())+1) + return m, createTempFile(m.textarea.Value(), m.textarea.Line()+1) } } @@ -149,7 +148,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { type startEditorMsg struct { path string - lineno uint + lineno int } type editorFinishedMsg struct { @@ -157,7 +156,7 @@ type editorFinishedMsg struct { err error } -func createTempFile(content string, lineno uint) tea.Cmd { +func createTempFile(content string, lineno int) tea.Cmd { return func() tea.Msg { f, err := os.CreateTemp("", "gum.*.md") if err != nil { @@ -175,7 +174,7 @@ func createTempFile(content string, lineno uint) tea.Cmd { } } -func openEditor(path string, lineno uint) tea.Cmd { +func openEditor(path string, lineno int) tea.Cmd { cb := func(err error) tea.Msg { if err != nil { return editorFinishedMsg{ From bff0c8584ef425795ed3bcad609d1c7417d360fd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Feb 2026 11:15:27 +0000 Subject: [PATCH 196/198] chore(deps): bump the all group with 3 updates (#1015) Bumps the all group with 3 updates: [github.com/alecthomas/kong](https://github.com/alecthomas/kong), [github.com/charmbracelet/bubbles](https://github.com/charmbracelet/bubbles) and [github.com/charmbracelet/x/ansi](https://github.com/charmbracelet/x). Updates `github.com/alecthomas/kong` from 1.13.0 to 1.14.0 - [Commits](https://github.com/alecthomas/kong/compare/v1.13.0...v1.14.0) Updates `github.com/charmbracelet/bubbles` from 0.21.0 to 0.21.1 - [Release notes](https://github.com/charmbracelet/bubbles/releases) - [Commits](https://github.com/charmbracelet/bubbles/compare/v0.21.0...v0.21.1) Updates `github.com/charmbracelet/x/ansi` from 0.11.4 to 0.11.5 - [Commits](https://github.com/charmbracelet/x/compare/ansi/v0.11.4...ansi/v0.11.5) --- updated-dependencies: - dependency-name: github.com/alecthomas/kong dependency-version: 1.14.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all - dependency-name: github.com/charmbracelet/bubbles dependency-version: 0.21.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: all - dependency-name: github.com/charmbracelet/x/ansi dependency-version: 0.11.5 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: all ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 12 ++++++------ go.sum | 28 ++++++++++++++-------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/go.mod b/go.mod index a0622c6..44aa346 100644 --- a/go.mod +++ b/go.mod @@ -4,14 +4,14 @@ go 1.24.2 require ( github.com/Masterminds/semver/v3 v3.4.0 - github.com/alecthomas/kong v1.13.0 + github.com/alecthomas/kong v1.14.0 github.com/alecthomas/mango-kong v0.1.0 - github.com/charmbracelet/bubbles v0.21.0 + github.com/charmbracelet/bubbles v0.21.1 github.com/charmbracelet/bubbletea v1.3.10 github.com/charmbracelet/glamour v0.10.0 github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 github.com/charmbracelet/log v0.4.2 - github.com/charmbracelet/x/ansi v0.11.4 + github.com/charmbracelet/x/ansi v0.11.5 github.com/charmbracelet/x/editor v0.2.0 github.com/charmbracelet/x/exp/ordered v0.1.0 github.com/charmbracelet/x/term v0.2.2 @@ -29,14 +29,14 @@ require ( github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymerick/douceur v0.2.0 // indirect github.com/charmbracelet/colorprofile v0.4.1 // indirect - github.com/charmbracelet/x/cellbuf v0.0.14 // indirect + github.com/charmbracelet/x/cellbuf v0.0.15 // indirect github.com/charmbracelet/x/conpty v0.1.1 // indirect github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 // indirect github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf // indirect github.com/charmbracelet/x/termios v0.1.1 // indirect - github.com/clipperhouse/displaywidth v0.7.0 // indirect + github.com/clipperhouse/displaywidth v0.9.0 // indirect github.com/clipperhouse/stringish v0.1.1 // indirect - github.com/clipperhouse/uax29/v2 v2.3.1 // indirect + github.com/clipperhouse/uax29/v2 v2.5.0 // indirect github.com/creack/pty v1.1.24 // indirect github.com/dlclark/regexp2 v1.11.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect diff --git a/go.sum b/go.sum index 85acb98..69eaec5 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8v github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E= github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I= -github.com/alecthomas/kong v1.13.0 h1:5e/7XC3ugvhP1DQBmTS+WuHtCbcv44hsohMgcvVxSrA= -github.com/alecthomas/kong v1.13.0/go.mod h1:wrlbXem1CWqUV5Vbmss5ISYhsVPkBb1Yo7YKJghju2I= +github.com/alecthomas/kong v1.14.0 h1:gFgEUZWu2ZmZ+UhyZ1bDhuutbKN1nTtJTwh19Wsn21s= +github.com/alecthomas/kong v1.14.0/go.mod h1:wrlbXem1CWqUV5Vbmss5ISYhsVPkBb1Yo7YKJghju2I= github.com/alecthomas/mango-kong v0.1.0 h1:iFVfP1k1K4qpml3JUQmD5I8MCQYfIvsD9mRdrw7jJC4= github.com/alecthomas/mango-kong v0.1.0/go.mod h1:t+TYVdsONUolf/BwVcm+15eqcdAj15h4Qe9MMFAwwT4= github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs= @@ -16,12 +16,12 @@ github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= -github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8= -github.com/aymanbagabas/go-udiff v0.2.0/go.mod h1:RE4Ex0qsGkTAJoQdQQCA0uG+nAzJO/pI/QwceO5fgrA= +github.com/aymanbagabas/go-udiff v0.3.1 h1:LV+qyBQ2pqe0u42ZsUEtPiCaUoqgA9gYRDs3vj1nolY= +github.com/aymanbagabas/go-udiff v0.3.1/go.mod h1:G0fsKmG+P6ylD0r6N/KgQD/nWzgfnl8ZBcNLgcbrw8E= github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= -github.com/charmbracelet/bubbles v0.21.0 h1:9TdC97SdRVg/1aaXNVWfFH3nnLAwOXr8Fn6u6mfQdFs= -github.com/charmbracelet/bubbles v0.21.0/go.mod h1:HF+v6QUR4HkEpz62dx7ym2xc71/KBHg+zKwJtMw+qtg= +github.com/charmbracelet/bubbles v0.21.1 h1:nj0decPiixaZeL9diI4uzzQTkkz1kYY8+jgzCZXSmW0= +github.com/charmbracelet/bubbles v0.21.1/go.mod h1:HHvIYRCpbkCJw2yo0vNX1O5loCwSr9/mWS8GYSg50Sk= github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw= github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4= github.com/charmbracelet/colorprofile v0.4.1 h1:a1lO03qTrSIRaK8c3JRxJDZOvhvIeSco3ej+ngLk1kk= @@ -32,10 +32,10 @@ github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 h1:ZR7e0r github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834/go.mod h1:aKC/t2arECF6rNOnaKaVU6y4t4ZeHQzqfxedE/VkVhA= github.com/charmbracelet/log v0.4.2 h1:hYt8Qj6a8yLnvR+h7MwsJv/XvmBJXiueUcI3cIxsyig= github.com/charmbracelet/log v0.4.2/go.mod h1:qifHGX/tc7eluv2R6pWIpyHDDrrb/AG71Pf2ysQu5nw= -github.com/charmbracelet/x/ansi v0.11.4 h1:6G65PLu6HjmE858CnTUQY1LXT3ZUWwfvqEROLF8vqHI= -github.com/charmbracelet/x/ansi v0.11.4/go.mod h1:/5AZ+UfWExW3int5H5ugnsG/PWjNcSQcwYsHBlPFQN4= -github.com/charmbracelet/x/cellbuf v0.0.14 h1:iUEMryGyFTelKW3THW4+FfPgi4fkmKnnaLOXuc+/Kj4= -github.com/charmbracelet/x/cellbuf v0.0.14/go.mod h1:P447lJl49ywBbil/KjCk2HexGh4tEY9LH0/1QrZZ9rA= +github.com/charmbracelet/x/ansi v0.11.5 h1:NBWeBpj/lJPE3Q5l+Lusa4+mH6v7487OP8K0r1IhRg4= +github.com/charmbracelet/x/ansi v0.11.5/go.mod h1:2JNYLgQUsyqaiLovhU2Rv/pb8r6ydXKS3NIttu3VGZQ= +github.com/charmbracelet/x/cellbuf v0.0.15 h1:ur3pZy0o6z/R7EylET877CBxaiE1Sp1GMxoFPAIztPI= +github.com/charmbracelet/x/cellbuf v0.0.15/go.mod h1:J1YVbR7MUuEGIFPCaaZ96KDl5NoS0DAWkskup+mOY+Q= github.com/charmbracelet/x/conpty v0.1.1 h1:s1bUxjoi7EpqiXysVtC+a8RrvPPNcNvAjfi4jxsAuEs= github.com/charmbracelet/x/conpty v0.1.1/go.mod h1:OmtR77VODEFbiTzGE9G1XiRJAga6011PIm4u5fTNZpk= github.com/charmbracelet/x/editor v0.2.0 h1:7XLUKtaRaB8jN7bWU2p2UChiySyaAuIfYiIRg8gGWwk= @@ -54,12 +54,12 @@ github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8 github.com/charmbracelet/x/termios v0.1.1/go.mod h1:rB7fnv1TgOPOyyKRJ9o+AsTU/vK5WHJ2ivHeut/Pcwo= github.com/charmbracelet/x/xpty v0.1.3 h1:eGSitii4suhzrISYH50ZfufV3v085BXQwIytcOdFSsw= github.com/charmbracelet/x/xpty v0.1.3/go.mod h1:poPYpWuLDBFCKmKLDnhBp51ATa0ooD8FhypRwEFtH3Y= -github.com/clipperhouse/displaywidth v0.7.0 h1:QNv1GYsnLX9QBrcWUtMlogpTXuM5FVnBwKWp1O5NwmE= -github.com/clipperhouse/displaywidth v0.7.0/go.mod h1:R+kHuzaYWFkTm7xoMmK1lFydbci4X2CicfbGstSGg0o= +github.com/clipperhouse/displaywidth v0.9.0 h1:Qb4KOhYwRiN3viMv1v/3cTBlz3AcAZX3+y9OLhMtAtA= +github.com/clipperhouse/displaywidth v0.9.0/go.mod h1:aCAAqTlh4GIVkhQnJpbL0T/WfcrJXHcj8C0yjYcjOZA= github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs= github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA= -github.com/clipperhouse/uax29/v2 v2.3.1 h1:RjM8gnVbFbgI67SBekIC7ihFpyXwRPYWXn9BZActHbw= -github.com/clipperhouse/uax29/v2 v2.3.1/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g= +github.com/clipperhouse/uax29/v2 v2.5.0 h1:x7T0T4eTHDONxFJsL94uKNKPHrclyFI0lm7+w94cO8U= +github.com/clipperhouse/uax29/v2 v2.5.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g= github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s= github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= From 06d72ec646276e3d0010818afbb10ac089f27c34 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Feb 2026 11:00:03 +0000 Subject: [PATCH 197/198] chore(deps): bump the all group with 3 updates (#1016) Bumps the all group with 3 updates: [github.com/charmbracelet/bubbles](https://github.com/charmbracelet/bubbles), [github.com/charmbracelet/x/ansi](https://github.com/charmbracelet/x) and [golang.org/x/text](https://github.com/golang/text). Updates `github.com/charmbracelet/bubbles` from 0.21.1 to 1.0.0 - [Release notes](https://github.com/charmbracelet/bubbles/releases) - [Commits](https://github.com/charmbracelet/bubbles/compare/v0.21.1...v1.0.0) Updates `github.com/charmbracelet/x/ansi` from 0.11.5 to 0.11.6 - [Commits](https://github.com/charmbracelet/x/compare/ansi/v0.11.5...ansi/v0.11.6) Updates `golang.org/x/text` from 0.33.0 to 0.34.0 - [Release notes](https://github.com/golang/text/releases) - [Commits](https://github.com/golang/text/compare/v0.33.0...v0.34.0) --- updated-dependencies: - dependency-name: github.com/charmbracelet/bubbles dependency-version: 1.0.0 dependency-type: direct:production update-type: version-update:semver-major dependency-group: all - dependency-name: github.com/charmbracelet/x/ansi dependency-version: 0.11.6 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: all - dependency-name: golang.org/x/text dependency-version: 0.34.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 44aa346..55e2352 100644 --- a/go.mod +++ b/go.mod @@ -6,12 +6,12 @@ require ( github.com/Masterminds/semver/v3 v3.4.0 github.com/alecthomas/kong v1.14.0 github.com/alecthomas/mango-kong v0.1.0 - github.com/charmbracelet/bubbles v0.21.1 + github.com/charmbracelet/bubbles v1.0.0 github.com/charmbracelet/bubbletea v1.3.10 github.com/charmbracelet/glamour v0.10.0 github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 github.com/charmbracelet/log v0.4.2 - github.com/charmbracelet/x/ansi v0.11.5 + github.com/charmbracelet/x/ansi v0.11.6 github.com/charmbracelet/x/editor v0.2.0 github.com/charmbracelet/x/exp/ordered v0.1.0 github.com/charmbracelet/x/term v0.2.2 @@ -20,7 +20,7 @@ require ( github.com/muesli/termenv v0.16.0 github.com/rivo/uniseg v0.4.7 github.com/sahilm/fuzzy v0.1.1 - golang.org/x/text v0.33.0 + golang.org/x/text v0.34.0 ) require ( diff --git a/go.sum b/go.sum index 69eaec5..c3d39b7 100644 --- a/go.sum +++ b/go.sum @@ -20,8 +20,8 @@ github.com/aymanbagabas/go-udiff v0.3.1 h1:LV+qyBQ2pqe0u42ZsUEtPiCaUoqgA9gYRDs3v github.com/aymanbagabas/go-udiff v0.3.1/go.mod h1:G0fsKmG+P6ylD0r6N/KgQD/nWzgfnl8ZBcNLgcbrw8E= github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= -github.com/charmbracelet/bubbles v0.21.1 h1:nj0decPiixaZeL9diI4uzzQTkkz1kYY8+jgzCZXSmW0= -github.com/charmbracelet/bubbles v0.21.1/go.mod h1:HHvIYRCpbkCJw2yo0vNX1O5loCwSr9/mWS8GYSg50Sk= +github.com/charmbracelet/bubbles v1.0.0 h1:12J8/ak/uCZEMQ6KU7pcfwceyjLlWsDLAxB5fXonfvc= +github.com/charmbracelet/bubbles v1.0.0/go.mod h1:9d/Zd5GdnauMI5ivUIVisuEm3ave1XwXtD1ckyV6r3E= github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw= github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4= github.com/charmbracelet/colorprofile v0.4.1 h1:a1lO03qTrSIRaK8c3JRxJDZOvhvIeSco3ej+ngLk1kk= @@ -32,8 +32,8 @@ github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 h1:ZR7e0r github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834/go.mod h1:aKC/t2arECF6rNOnaKaVU6y4t4ZeHQzqfxedE/VkVhA= github.com/charmbracelet/log v0.4.2 h1:hYt8Qj6a8yLnvR+h7MwsJv/XvmBJXiueUcI3cIxsyig= github.com/charmbracelet/log v0.4.2/go.mod h1:qifHGX/tc7eluv2R6pWIpyHDDrrb/AG71Pf2ysQu5nw= -github.com/charmbracelet/x/ansi v0.11.5 h1:NBWeBpj/lJPE3Q5l+Lusa4+mH6v7487OP8K0r1IhRg4= -github.com/charmbracelet/x/ansi v0.11.5/go.mod h1:2JNYLgQUsyqaiLovhU2Rv/pb8r6ydXKS3NIttu3VGZQ= +github.com/charmbracelet/x/ansi v0.11.6 h1:GhV21SiDz/45W9AnV2R61xZMRri5NlLnl6CVF7ihZW8= +github.com/charmbracelet/x/ansi v0.11.6/go.mod h1:2JNYLgQUsyqaiLovhU2Rv/pb8r6ydXKS3NIttu3VGZQ= github.com/charmbracelet/x/cellbuf v0.0.15 h1:ur3pZy0o6z/R7EylET877CBxaiE1Sp1GMxoFPAIztPI= github.com/charmbracelet/x/cellbuf v0.0.15/go.mod h1:J1YVbR7MUuEGIFPCaaZ96KDl5NoS0DAWkskup+mOY+Q= github.com/charmbracelet/x/conpty v0.1.1 h1:s1bUxjoi7EpqiXysVtC+a8RrvPPNcNvAjfi4jxsAuEs= @@ -128,7 +128,7 @@ golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg= golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= -golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE= -golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8= +golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk= +golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 4409974788c69546c80e5b0f093b904a1e4aed6e Mon Sep 17 00:00:00 2001 From: rohan436 Date: Sat, 14 Mar 2026 15:09:45 +0800 Subject: [PATCH 198/198] docs: fix README wording --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9c66554..80a2b67 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ The above example is running from a single shell script ([source](./examples/dem ## Tutorial Gum provides highly configurable, ready-to-use utilities to help you write -useful shell scripts and dotfiles aliases with just a few lines of code. +useful shell scripts and dotfile aliases with just a few lines of code. Let's build a simple script to help you write [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) for your dotfiles.