From 3076547ce8f9c1f1bb63f11a1d122bddac7478a8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 03:56:16 +0000 Subject: [PATCH] =?UTF-8?q?chore(deps):=20update=20=F0=9F=A4=96=20mage=20t?= =?UTF-8?q?ooling=20to=20v0.12.79=20(#128)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/pterm/pterm](https://togithub.com/pterm/pterm) | `v0.12.78` -> `v0.12.79` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fpterm%2fpterm/v0.12.79?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fpterm%2fpterm/v0.12.79?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fpterm%2fpterm/v0.12.78/v0.12.79?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fpterm%2fpterm/v0.12.78/v0.12.79?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/sheldonhull/magetools). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 +- vendor/github.com/pterm/pterm/README.md | 35 ++++++++++-- .../pterm/interactive_multiselect_printer.go | 2 +- .../pterm/pterm/interactive_select_printer.go | 2 +- .../pterm/interactive_textinput_printer.go | 54 ++++++++++++++++--- vendor/modules.txt | 2 +- 7 files changed, 85 insertions(+), 16 deletions(-) diff --git a/go.mod b/go.mod index 94bc5167..b994421b 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/dustin/go-humanize v1.0.1 github.com/magefile/mage v1.15.0 github.com/matryer/is v1.4.1 - github.com/pterm/pterm v0.12.78 + github.com/pterm/pterm v0.12.79 github.com/ztrue/tracerr v0.4.0 golang.org/x/mod v0.14.0 ) diff --git a/go.sum b/go.sum index 43107462..8e494108 100644 --- a/go.sum +++ b/go.sum @@ -74,8 +74,8 @@ github.com/pterm/pterm v0.12.31/go.mod h1:32ZAWZVXD7ZfG0s8qqHXePte42kdz8ECtRyEej github.com/pterm/pterm v0.12.33/go.mod h1:x+h2uL+n7CP/rel9+bImHD5lF3nM9vJj80k9ybiiTTE= github.com/pterm/pterm v0.12.36/go.mod h1:NjiL09hFhT/vWjQHSj1athJpx6H8cjpHXNAK5bUw8T8= github.com/pterm/pterm v0.12.40/go.mod h1:ffwPLwlbXxP+rxT0GsgDTzS3y3rmpAO1NMjUkGTYf8s= -github.com/pterm/pterm v0.12.78 h1:QTWKaIAa4B32GKwqVXtu9m1DUMgWw3VRljMkMevX+b8= -github.com/pterm/pterm v0.12.78/go.mod h1:1v/gzOF1N0FsjbgTHZ1wVycRkKiatFvJSJC4IGaQAAo= +github.com/pterm/pterm v0.12.79 h1:lH3yrYMhdpeqX9y5Ep1u7DejyHy7NSQg9qrBjF9dFT4= +github.com/pterm/pterm v0.12.79/go.mod h1:1v/gzOF1N0FsjbgTHZ1wVycRkKiatFvJSJC4IGaQAAo= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= diff --git a/vendor/github.com/pterm/pterm/README.md b/vendor/github.com/pterm/pterm/README.md index c7a37292..6a9cd784 100644 --- a/vendor/github.com/pterm/pterm/README.md +++ b/vendor/github.com/pterm/pterm/README.md @@ -2388,11 +2388,38 @@ import ( ) func main() { - // Create an interactive text input with single line input mode - textInput := pterm.DefaultInteractiveTextInput.WithMultiLine(false) + // Create an interactive text input with single line input mode and show it + result, _ := pterm.DefaultInteractiveTextInput.Show() - // Show the text input and get the result - result, _ := textInput.Show() + // Print a blank line for better readability + pterm.Println() + + // Print the user's answer with an info prefix + pterm.Info.Printfln("You answered: %s", result) +} + +``` + + + +### interactive_textinput/default-value + +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/interactive_textinput/default-value/animation.svg) + +
+ +SHOW SOURCE + +```go +package main + +import ( + "github.com/pterm/pterm" +) + +func main() { + // Create an interactive text input with single line input mode and show it + result, _ := pterm.DefaultInteractiveTextInput.WithDefaultValue("Some default value").Show() // Print a blank line for better readability pterm.Println() diff --git a/vendor/github.com/pterm/pterm/interactive_multiselect_printer.go b/vendor/github.com/pterm/pterm/interactive_multiselect_printer.go index 754ba98a..9dce03fb 100644 --- a/vendor/github.com/pterm/pterm/interactive_multiselect_printer.go +++ b/vendor/github.com/pterm/pterm/interactive_multiselect_printer.go @@ -206,7 +206,7 @@ func (p *InteractiveMultiselectPrinter) Show(text ...string) ([]string, error) { } case keys.Backspace: // Remove last character from fuzzy search string - if len(p.fuzzySearchString) > 0 { + if p.fuzzySearchString != "" { // Handle UTF-8 characters p.fuzzySearchString = string([]rune(p.fuzzySearchString)[:len([]rune(p.fuzzySearchString))-1]) } diff --git a/vendor/github.com/pterm/pterm/interactive_select_printer.go b/vendor/github.com/pterm/pterm/interactive_select_printer.go index 0c4bc995..d62f5dad 100644 --- a/vendor/github.com/pterm/pterm/interactive_select_printer.go +++ b/vendor/github.com/pterm/pterm/interactive_select_printer.go @@ -173,7 +173,7 @@ func (p *InteractiveSelectPrinter) Show(text ...string) (string, error) { area.Update(p.renderSelectMenu()) case keys.Backspace: // Remove last character from fuzzy search string - if len(p.fuzzySearchString) > 0 { + if p.fuzzySearchString != "" { // Handle UTF-8 characters p.fuzzySearchString = string([]rune(p.fuzzySearchString)[:len([]rune(p.fuzzySearchString))-1]) } diff --git a/vendor/github.com/pterm/pterm/interactive_textinput_printer.go b/vendor/github.com/pterm/pterm/interactive_textinput_printer.go index 1989fc80..6926a4be 100644 --- a/vendor/github.com/pterm/pterm/interactive_textinput_printer.go +++ b/vendor/github.com/pterm/pterm/interactive_textinput_printer.go @@ -29,10 +29,12 @@ type InteractiveTextInputPrinter struct { Mask string OnInterruptFunc func() - input []string - cursorXPos int - cursorYPos int - text string + input []string + cursorXPos int + cursorYPos int + text string + startedTyping bool + valueStyle *Style } // WithDefaultText sets the default text. @@ -86,7 +88,7 @@ func (p InteractiveTextInputPrinter) Show(text ...string) (string, error) { var areaText string - if len(text) == 0 || Sprint(text[0]) == "" { + if len(text) == 0 || text[0] == "" { text = []string{p.DefaultText} } @@ -106,7 +108,7 @@ func (p InteractiveTextInputPrinter) Show(text ...string) (string, error) { } if p.DefaultValue != "" { - p.input = append(p.input, p.DefaultValue) + p.input = append(p.input, Gray(p.DefaultValue)) p.updateArea(&area) } @@ -125,6 +127,17 @@ func (p InteractiveTextInputPrinter) Show(text ...string) (string, error) { return true, nil } case keys.Enter: + if p.DefaultValue != "" && !p.startedTyping { + for i := range p.input { + p.input[i] = RemoveColorFromString(p.input[i]) + } + + if p.MultiLine { + area.Bottom() + } + return true, nil + } + if p.MultiLine { if key.AltPressed { p.cursorXPos = 0 @@ -141,10 +154,22 @@ func (p InteractiveTextInputPrinter) Show(text ...string) (string, error) { return true, nil } case keys.RuneKey: + if !p.startedTyping { + p.input = []string{""} + p.startedTyping = true + } p.input[p.cursorYPos] = string(append([]rune(p.input[p.cursorYPos])[:len([]rune(p.input[p.cursorYPos]))+p.cursorXPos], append([]rune(key.String()), []rune(p.input[p.cursorYPos])[len([]rune(p.input[p.cursorYPos]))+p.cursorXPos:]...)...)) case keys.Space: + if !p.startedTyping { + p.input = []string{" "} + p.startedTyping = true + } p.input[p.cursorYPos] = string(append([]rune(p.input[p.cursorYPos])[:len([]rune(p.input[p.cursorYPos]))+p.cursorXPos], append([]rune(" "), []rune(p.input[p.cursorYPos])[len([]rune(p.input[p.cursorYPos]))+p.cursorXPos:]...)...)) case keys.Backspace: + if !p.startedTyping { + p.input = []string{""} + p.startedTyping = true + } if len([]rune(p.input[p.cursorYPos]))+p.cursorXPos > 0 { p.input[p.cursorYPos] = string(append([]rune(p.input[p.cursorYPos])[:len([]rune(p.input[p.cursorYPos]))-1+p.cursorXPos], []rune(p.input[p.cursorYPos])[len([]rune(p.input[p.cursorYPos]))+p.cursorXPos:]...)) } else if p.cursorYPos > 0 { @@ -155,6 +180,11 @@ func (p InteractiveTextInputPrinter) Show(text ...string) (string, error) { p.cursorYPos-- } case keys.Delete: + if !p.startedTyping { + p.input = []string{""} + p.startedTyping = true + return false, nil + } if len([]rune(p.input[p.cursorYPos]))+p.cursorXPos < len([]rune(p.input[p.cursorYPos])) { p.input[p.cursorYPos] = string(append([]rune(p.input[p.cursorYPos])[:len([]rune(p.input[p.cursorYPos]))+p.cursorXPos], []rune(p.input[p.cursorYPos])[len([]rune(p.input[p.cursorYPos]))+p.cursorXPos+1:]...)) p.cursorXPos++ @@ -168,6 +198,10 @@ func (p InteractiveTextInputPrinter) Show(text ...string) (string, error) { cancel() return true, nil case keys.Down: + if !p.startedTyping { + p.input = []string{""} + p.startedTyping = true + } if p.cursorYPos+1 < len(p.input) { p.cursorXPos = (internal.GetStringMaxWidth(p.input[p.cursorYPos]) + p.cursorXPos) - internal.GetStringMaxWidth(p.input[p.cursorYPos+1]) if p.cursorXPos > 0 { @@ -176,6 +210,10 @@ func (p InteractiveTextInputPrinter) Show(text ...string) (string, error) { p.cursorYPos++ } case keys.Up: + if !p.startedTyping { + p.input = []string{""} + p.startedTyping = true + } if p.cursorYPos > 0 { p.cursorXPos = (internal.GetStringMaxWidth(p.input[p.cursorYPos]) + p.cursorXPos) - internal.GetStringMaxWidth(p.input[p.cursorYPos-1]) if p.cursorXPos > 0 { @@ -223,6 +261,10 @@ func (p InteractiveTextInputPrinter) Show(text ...string) (string, error) { } } + if !p.startedTyping { + return p.DefaultValue, nil + } + return strings.ReplaceAll(areaText, p.text, ""), nil } diff --git a/vendor/modules.txt b/vendor/modules.txt index 59ce9eba..81dbb776 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -40,7 +40,7 @@ github.com/matryer/is # github.com/mattn/go-runewidth v0.0.15 ## explicit; go 1.9 github.com/mattn/go-runewidth -# github.com/pterm/pterm v0.12.78 +# github.com/pterm/pterm v0.12.79 ## explicit; go 1.21 github.com/pterm/pterm github.com/pterm/pterm/internal