diff --git a/cmd/add.go b/cmd/add.go index 0fdd1ab..5517ca1 100644 --- a/cmd/add.go +++ b/cmd/add.go @@ -3,7 +3,7 @@ package cmd import ( "fmt" - "github.com/cli/go-gh/v2/pkg/prompter" + "github.com/github/gh-stack/internal/prompter" "github.com/github/gh-stack/internal/branch" "github.com/github/gh-stack/internal/config" "github.com/github/gh-stack/internal/git" diff --git a/cmd/checkout.go b/cmd/checkout.go index d66087c..5b86fe5 100644 --- a/cmd/checkout.go +++ b/cmd/checkout.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/cli/go-gh/v2/pkg/api" - "github.com/cli/go-gh/v2/pkg/prompter" + "github.com/github/gh-stack/internal/prompter" "github.com/github/gh-stack/internal/config" "github.com/github/gh-stack/internal/git" "github.com/github/gh-stack/internal/github" @@ -376,7 +376,6 @@ func handleCompositionConflict( selected, err := p.Select("How would you like to resolve this?", "", options) if err != nil { if isInterruptError(err) { - clearSelectPrompt(cfg, len(options)) printInterrupt(cfg) return nil, errInterrupt } @@ -574,7 +573,6 @@ func interactiveStackPicker(cfg *config.Config, sf *stack.StackFile) (*stack.Sta ) if err != nil { if isInterruptError(err) { - clearSelectPrompt(cfg, len(options)) printInterrupt(cfg) return nil, errInterrupt } diff --git a/cmd/init.go b/cmd/init.go index f625814..9e66f23 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/cli/go-gh/v2/pkg/prompter" + "github.com/github/gh-stack/internal/prompter" "github.com/github/gh-stack/internal/branch" "github.com/github/gh-stack/internal/config" "github.com/github/gh-stack/internal/git" diff --git a/cmd/merge.go b/cmd/merge.go index 8a298e2..3367712 100644 --- a/cmd/merge.go +++ b/cmd/merge.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/cli/go-gh/v2/pkg/browser" - "github.com/cli/go-gh/v2/pkg/prompter" + "github.com/github/gh-stack/internal/prompter" "github.com/github/gh-stack/internal/config" "github.com/github/gh-stack/internal/stack" "github.com/spf13/cobra" diff --git a/cmd/push.go b/cmd/push.go index 1f0f857..2bd1c4f 100644 --- a/cmd/push.go +++ b/cmd/push.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - "github.com/cli/go-gh/v2/pkg/prompter" + "github.com/github/gh-stack/internal/prompter" "github.com/github/gh-stack/internal/config" "github.com/github/gh-stack/internal/git" "github.com/github/gh-stack/internal/modify" @@ -151,7 +151,6 @@ func pickRemote(cfg *config.Config, branch, remoteOverride string) (string, erro selected, promptErr := p.Select("Multiple remotes found. Which remote should be used?", "", multi.Remotes) if promptErr != nil { if isInterruptError(promptErr) { - clearSelectPrompt(cfg, len(multi.Remotes)) printInterrupt(cfg) return "", errInterrupt } diff --git a/cmd/root.go b/cmd/root.go index c566aba..301bba7 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -69,6 +69,9 @@ func Execute() { wrapCmd.SetArgs(append([]string{"stack"}, os.Args[1:]...)) if err := wrapCmd.Execute(); err != nil { + if errors.Is(err, errInterrupt) { + os.Exit(1) + } var exitErr *ExitError if errors.As(err, &exitErr) { os.Exit(exitErr.Code) diff --git a/cmd/submit.go b/cmd/submit.go index a830177..ac232f4 100644 --- a/cmd/submit.go +++ b/cmd/submit.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/cli/go-gh/v2/pkg/api" - "github.com/cli/go-gh/v2/pkg/prompter" + "github.com/github/gh-stack/internal/prompter" "github.com/github/gh-stack/internal/config" "github.com/github/gh-stack/internal/git" "github.com/github/gh-stack/internal/github" @@ -84,8 +84,12 @@ func runSubmit(cfg *config.Config, opts *submitOptions) error { if _, err := client.ListStacks(); err != nil { cfg.Warningf("Stacked PRs are not enabled for this repository") if cfg.IsInteractive() { - p := prompter.New(cfg.In, cfg.Out, cfg.Err) - proceed, promptErr := p.Confirm("Would you still like to create regular PRs?", false) + confirmFn := cfg.ConfirmFn + if confirmFn == nil { + p := prompter.New(cfg.In, cfg.Out, cfg.Err) + confirmFn = p.Confirm + } + proceed, promptErr := confirmFn("Would you still like to create regular PRs?", false) if promptErr != nil { if isInterruptError(promptErr) { printInterrupt(cfg) diff --git a/cmd/submit_test.go b/cmd/submit_test.go index 2b0e40d..bce92f6 100644 --- a/cmd/submit_test.go +++ b/cmd/submit_test.go @@ -5,7 +5,6 @@ import ( "fmt" "io" "net/url" - "os" "testing" "github.com/cli/go-gh/v2/pkg/api" @@ -905,15 +904,11 @@ func TestSubmit_PreflightCheck_404_Interactive_UserDeclinesAborts(t *testing.T) restore := git.SetOps(mock) defer restore() - // Force interactive mode; survey will fail on the pipe, - // which is treated as a decline — same as user saying "no". - inR, inW, _ := os.Pipe() - inW.Close() - defer inR.Close() - cfg, _, errR := config.NewTestConfig() - cfg.In = inR cfg.ForceInteractive = true + cfg.ConfirmFn = func(prompt string, defaultValue bool) (bool, error) { + return false, nil // user declines + } cfg.GitHubClientOverride = &github.MockClient{ ListStacksFn: func() ([]github.RemoteStack, error) { return nil, &api.HTTPError{StatusCode: 404, Message: "Not Found"} diff --git a/cmd/switch.go b/cmd/switch.go index 3e7cbcd..21bef2b 100644 --- a/cmd/switch.go +++ b/cmd/switch.go @@ -3,7 +3,7 @@ package cmd import ( "fmt" - "github.com/cli/go-gh/v2/pkg/prompter" + "github.com/github/gh-stack/internal/prompter" "github.com/github/gh-stack/internal/config" "github.com/github/gh-stack/internal/git" "github.com/spf13/cobra" @@ -68,7 +68,6 @@ func runSwitch(cfg *config.Config) error { selected, err := selectFn("Select a branch in the stack to switch to:", defaultOpt, options) if err != nil { if isInterruptError(err) { - clearSelectPrompt(cfg, len(options)) printInterrupt(cfg) return errInterrupt } diff --git a/cmd/utils.go b/cmd/utils.go index 09e95e5..9ec401a 100644 --- a/cmd/utils.go +++ b/cmd/utils.go @@ -7,8 +7,7 @@ import ( "strconv" "strings" - "github.com/AlecAivazis/survey/v2/terminal" - "github.com/cli/go-gh/v2/pkg/prompter" + "github.com/github/gh-stack/internal/prompter" "github.com/github/gh-stack/internal/config" "github.com/github/gh-stack/internal/git" "github.com/github/gh-stack/internal/github" @@ -54,36 +53,18 @@ func (e *ExitError) Is(target error) bool { // Callers should exit silently (the friendly message is already printed). var errInterrupt = errors.New("interrupt") -// isInterruptError reports whether err is (or wraps) the survey interrupt, +// isInterruptError reports whether err is (or wraps) the prompt interrupt, // which is raised when the user presses Ctrl+C during a prompt. func isInterruptError(err error) bool { - return errors.Is(err, terminal.InterruptErr) + return errors.Is(err, prompter.ErrInterrupt) } // printInterrupt prints a friendly message and should be called exactly once -// per interrupted operation. The leading newline ensures the message starts -// on its own line even if the cursor was mid-prompt. +// per interrupted operation. func printInterrupt(cfg *config.Config) { - fmt.Fprintln(cfg.Err) cfg.Infof("Received interrupt, aborting operation") } -// selectPromptPageSize matches the PageSize used by the go-gh prompter. -const selectPromptPageSize = 20 - -// clearSelectPrompt erases the rendered Select prompt from the terminal. -// survey/v2 does not call Cleanup on interrupt, leaving the question and -// option lines visible. This function moves the cursor up past those lines -// and clears to the end of the screen. -func clearSelectPrompt(cfg *config.Config, numOptions int) { - visible := numOptions - if visible > selectPromptPageSize { - visible = selectPromptPageSize - } - // 1 line for the question/filter + visible option lines - lines := 1 + visible - fmt.Fprintf(cfg.Out, "\033[%dA\033[J", lines) -} // loadStackResult holds everything returned by loadStack. type loadStackResult struct { @@ -206,7 +187,6 @@ func resolveStack(sf *stack.StackFile, branch string, cfg *config.Config) (*stac selected, err := p.Select("Which stack would you like to use?", "", options) if err != nil { if isInterruptError(err) { - clearSelectPrompt(cfg, len(options)) printInterrupt(cfg) return nil, errInterrupt } diff --git a/cmd/utils_test.go b/cmd/utils_test.go index 2f9c7b4..ee52f06 100644 --- a/cmd/utils_test.go +++ b/cmd/utils_test.go @@ -6,24 +6,24 @@ import ( "strings" "testing" - "github.com/AlecAivazis/survey/v2/terminal" "github.com/github/gh-stack/internal/config" "github.com/github/gh-stack/internal/git" "github.com/github/gh-stack/internal/github" + "github.com/github/gh-stack/internal/prompter" "github.com/github/gh-stack/internal/stack" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestIsInterruptError_DirectMatch(t *testing.T) { - if !isInterruptError(terminal.InterruptErr) { - t.Error("expected true for terminal.InterruptErr") + if !isInterruptError(prompter.ErrInterrupt) { + t.Error("expected true for prompter.ErrInterrupt") } } func TestIsInterruptError_Wrapped(t *testing.T) { // This is how the prompter library wraps the interrupt error. - wrapped := fmt.Errorf("could not prompt: %w", terminal.InterruptErr) + wrapped := fmt.Errorf("could not prompt: %w", prompter.ErrInterrupt) if !isInterruptError(wrapped) { t.Error("expected true for wrapped interrupt error") } @@ -31,7 +31,7 @@ func TestIsInterruptError_Wrapped(t *testing.T) { func TestIsInterruptError_DoubleWrapped(t *testing.T) { // Simulate additional wrapping by callers. - inner := fmt.Errorf("could not prompt: %w", terminal.InterruptErr) + inner := fmt.Errorf("could not prompt: %w", prompter.ErrInterrupt) outer := fmt.Errorf("stack selection: %w", inner) if !isInterruptError(outer) { t.Error("expected true for double-wrapped interrupt error") @@ -65,8 +65,10 @@ func TestPrintInterrupt_Output(t *testing.T) { } func TestErrInterrupt_IsDistinct(t *testing.T) { - if errors.Is(errInterrupt, terminal.InterruptErr) { - t.Error("errInterrupt sentinel should not match terminal.InterruptErr") + // errInterrupt (the cmd-level sentinel) and prompter.ErrInterrupt + // are distinct errors — they should not match each other. + if errors.Is(errInterrupt, prompter.ErrInterrupt) { + t.Error("errInterrupt sentinel should not match prompter.ErrInterrupt") } if !errors.Is(errInterrupt, errInterrupt) { t.Error("errInterrupt should match itself") diff --git a/go.mod b/go.mod index 9b1ab65..00105a9 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,10 @@ module github.com/github/gh-stack -go 1.25.7 +go 1.25.8 require ( - github.com/AlecAivazis/survey/v2 v2.3.7 + charm.land/huh/v2 v2.0.3 + charm.land/lipgloss/v2 v2.0.1 github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7 github.com/charmbracelet/bubbletea v1.3.10 github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 @@ -13,40 +14,51 @@ require ( github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d github.com/spf13/cobra v1.10.2 github.com/stretchr/testify v1.11.1 - golang.org/x/sys v0.39.0 + golang.org/x/sys v0.42.0 golang.org/x/text v0.32.0 ) require ( + charm.land/bubbles/v2 v2.0.0 // indirect + charm.land/bubbletea/v2 v2.0.2 // indirect github.com/atotto/clipboard v0.1.4 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect - github.com/charmbracelet/colorprofile v0.3.1 // indirect - github.com/charmbracelet/x/ansi v0.10.2 // indirect - github.com/charmbracelet/x/cellbuf v0.0.13 // indirect - github.com/charmbracelet/x/term v0.2.1 // indirect + github.com/catppuccin/go v0.3.0 // indirect + github.com/charmbracelet/colorprofile v0.4.2 // indirect + github.com/charmbracelet/ultraviolet v0.0.0-20260205113103-524a6607adb8 // indirect + github.com/charmbracelet/x/ansi v0.11.6 // indirect + github.com/charmbracelet/x/cellbuf v0.0.15 // indirect + github.com/charmbracelet/x/exp/ordered v0.1.0 // indirect + github.com/charmbracelet/x/exp/strings v0.0.0-20250630141444-821143405392 // indirect + github.com/charmbracelet/x/term v0.2.2 // indirect + github.com/charmbracelet/x/termios v0.1.1 // indirect + github.com/charmbracelet/x/windows v0.2.2 // indirect github.com/cli/browser v1.3.0 // indirect github.com/cli/safeexec v1.0.1 // indirect + github.com/clipperhouse/displaywidth v0.11.0 // indirect + github.com/clipperhouse/uax29/v2 v2.7.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/dustin/go-humanize v1.0.1 // indirect github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/henvic/httpretty v0.1.4 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/lucasb-eyer/go-colorful v1.3.0 // indirect github.com/mattn/go-colorable v0.1.14 // 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.20 // 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/reflow v0.3.0 // indirect github.com/muesli/termenv v0.16.0 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/spf13/pflag v1.0.10 // indirect github.com/thlib/go-timezone-local v0.0.6 // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect + golang.org/x/sync v0.19.0 // indirect golang.org/x/term v0.38.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index f43d5f0..335613e 100644 --- a/go.sum +++ b/go.sum @@ -1,31 +1,53 @@ -github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ= -github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo= +charm.land/bubbles/v2 v2.0.0 h1:tE3eK/pHjmtrDiRdoC9uGNLgpopOd8fjhEe31B/ai5s= +charm.land/bubbles/v2 v2.0.0/go.mod h1:rCHoleP2XhU8um45NTuOWBPNVHxnkXKTiZqcclL/qOI= +charm.land/bubbletea/v2 v2.0.2 h1:4CRtRnuZOdFDTWSff9r8QFt/9+z6Emubz3aDMnf/dx0= +charm.land/bubbletea/v2 v2.0.2/go.mod h1:3LRff2U4WIYXy7MTxfbAQ+AdfM3D8Xuvz2wbsOD9OHQ= +charm.land/huh/v2 v2.0.3 h1:2cJsMqEPwSywGHvdlKsJyQKPtSJLVnFKyFbsYZTlLkU= +charm.land/huh/v2 v2.0.3/go.mod h1:93eEveeeqn47MwiC3tf+2atZ2l7Is88rAtmZNZ8x9Wc= +charm.land/lipgloss/v2 v2.0.1 h1:6Xzrn49+Py1Um5q/wZG1gWgER2+7dUyZ9XMEufqPSys= +charm.land/lipgloss/v2 v2.0.1/go.mod h1:KjPle2Qd3YmvP1KL5OMHiHysGcNwq6u83MUjYkFvEkM= github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= -github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s= -github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w= 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= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= -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/aymanbagabas/go-udiff v0.4.1 h1:OEIrQ8maEeDBXQDoGCbbTTXYJMYRCRO1fnodZ12Gv5o= +github.com/aymanbagabas/go-udiff v0.4.1/go.mod h1:0L9PGwj20lrtmEMeyw4WKJ/TMyDtvAoK9bf2u/mNo3w= +github.com/catppuccin/go v0.3.0 h1:d+0/YicIq+hSTo5oPuRi5kOpqkVA5tAsU6dNhvRu+aY= +github.com/catppuccin/go v0.3.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc= github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7 h1:JFgG/xnwFfbezlUnFMJy0nusZvytYysV4SCS2cYbvws= github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7/go.mod h1:ISC1gtLcVilLOf23wvTfoQuYbW2q0JevFxPfUzZ9Ybw= 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.3.1 h1:k8dTHMd7fgw4bnFd7jXTLZrSU/CQrKnL3m+AxCzDz40= -github.com/charmbracelet/colorprofile v0.3.1/go.mod h1:/GkGusxNs8VB/RSOh3fu0TJmQ4ICMMPApIIVn0KszZ0= +github.com/charmbracelet/colorprofile v0.4.2 h1:BdSNuMjRbotnxHSfxy+PCSa4xAmz7szw70ktAtWRYrY= +github.com/charmbracelet/colorprofile v0.4.2/go.mod h1:0rTi81QpwDElInthtrQ6Ni7cG0sDtwAd4C4le060fT8= 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/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/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/ultraviolet v0.0.0-20260205113103-524a6607adb8 h1:eyFRbAmexyt43hVfeyBofiGSEmJ7krjLOYt/9CF5NKA= +github.com/charmbracelet/ultraviolet v0.0.0-20260205113103-524a6607adb8/go.mod h1:SQpCTRNBtzJkwku5ye4S3HEuthAlGy2n9VXZnWkEW98= +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= +github.com/charmbracelet/x/conpty v0.1.1/go.mod h1:OmtR77VODEFbiTzGE9G1XiRJAga6011PIm4u5fTNZpk= +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-20250806222409-83e3a29d542f h1:pk6gmGpCE7F3FcjaOEKYriCvpmIN4+6OS/RD0vm4uIA= +github.com/charmbracelet/x/exp/golden v0.0.0-20250806222409-83e3a29d542f/go.mod h1:IfZAMTHB6XkZSeXUqriemErjAWCCzT0LwjKFYCZyw0I= +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/strings v0.0.0-20250630141444-821143405392 h1:6ipGA1NEA0AZG2UEf81RQGJvEPvYLn/M18mZcdt4J8g= +github.com/charmbracelet/x/exp/strings v0.0.0-20250630141444-821143405392/go.mod h1:Rgw3/F+xlcUc5XygUtimVSxAqCOsqyvJjqF5UHRvc5k= +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/windows v0.2.2 h1:IofanmuvaxnKHuV04sC0eBy/smG6kIKrWG2/jYn2GuM= +github.com/charmbracelet/x/windows v0.2.2/go.mod h1:/8XtdKZzedat74NQFn0NGlGL4soHB0YQZrETF96h75k= +github.com/charmbracelet/x/xpty v0.1.3 h1:eGSitii4suhzrISYH50ZfufV3v085BXQwIytcOdFSsw= +github.com/charmbracelet/x/xpty v0.1.3/go.mod h1:poPYpWuLDBFCKmKLDnhBp51ATa0ooD8FhypRwEFtH3Y= github.com/cli/browser v1.3.0 h1:LejqCrpWr+1pRqmEPDGnTZOjsMe7sehifLynZJuqJpo= github.com/cli/browser v1.3.0/go.mod h1:HH8s+fOAxjhQoBUAsKuPCbqUuxZDhQ2/aD+SzsEfBTk= github.com/cli/cli/v2 v2.86.0 h1:114DaPhDvKNMp8MTLffN119mHe040eNhNgLv3qi3mNA= @@ -36,15 +58,18 @@ github.com/cli/safeexec v1.0.1 h1:e/C79PbXF4yYTN/wauC4tviMxEV13BwljGj0N9j+N00= github.com/cli/safeexec v1.0.1/go.mod h1:Z/D4tTN8Vs5gXYHDCbaM1S/anmEDnJb1iW0+EJ5zx3Q= github.com/cli/shurcooL-graphql v0.0.4 h1:6MogPnQJLjKkaXPyGqPRXOI2qCsQdqNfUY1QSJu2GuY= github.com/cli/shurcooL-graphql v0.0.4/go.mod h1:3waN4u02FiZivIV+p1y4d0Jo1jc6BViMA73C+sZo2fk= +github.com/clipperhouse/displaywidth v0.11.0 h1:lBc6kY44VFw+TDx4I8opi/EtL9m20WSEFgwIwO+UVM8= +github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3JhNl3dSqnGhOoSD/o0= +github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk= +github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= 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.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4= github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= @@ -53,46 +78,35 @@ github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslC github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= github.com/henvic/httpretty v0.1.4 h1:Jo7uwIRWVFxkqOnErcoYfH90o3ddQyVrSANeS4cxYmU= github.com/henvic/httpretty v0.1.4/go.mod h1:Dn60sQTZfbt2dYsdUSNsCljyF4AfdqnuJFDLJA1I4AM= -github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec h1:qv2VnGeEQHchGaZ/u7lxST/RaJw+cv273q79D81Xbog= -github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= -github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= 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-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= 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.17 h1:78v8ZlW0bP43XfmAfPsdXcoNCelfMHsDmd/pkENfrjQ= -github.com/mattn/go-runewidth v0.0.17/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= +github.com/mattn/go-runewidth v0.0.20 h1:WcT52H91ZUAwy8+HUkdM3THM6gXqXuLJi9O3rjcQQaQ= +github.com/mattn/go-runewidth v0.0.20/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs= github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI= github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= +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= github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo= -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/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc= github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= @@ -103,58 +117,32 @@ github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiT github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/thlib/go-timezone-local v0.0.6 h1:Ii3QJ4FhosL/+eCZl6Hsdr4DDU4tfevNoV83yAEo2tU= github.com/thlib/go-timezone-local v0.0.6/go.mod h1:/Tnicc6m/lsJE0irFMA0LfIwTBo4QP7A8IfyIv4zZKI= 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.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E= -golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= +golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= +golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= -golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo= +golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= golang.org/x/term v0.38.0 h1:PQ5pkm/rLO6HnxFR7N2lJHOZX6Kez5Y1gDSJla6jo7Q= golang.org/x/term v0.38.0/go.mod h1:bSEAKrOT1W+VSu9TSCMtoGEOUcKxOKgl3LE5QEF/xVg= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ= golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY= gopkg.in/h2non/gock.v1 v1.1.2/go.mod h1:n7UGz/ckNChHiK05rDoiC4MYSunEC/lyaUm2WWaDva0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/config/config.go b/internal/config/config.go index e706dd0..1685b01 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -38,6 +38,14 @@ type Config struct { // SelectFn, when non-nil, is called instead of prompting via the // terminal. Used in tests to simulate interactive selection. SelectFn func(prompt, defaultValue string, options []string) (int, error) + + // ConfirmFn, when non-nil, is called instead of prompting via the + // terminal. Used in tests to simulate interactive confirmation. + ConfirmFn func(prompt string, defaultValue bool) (bool, error) + + // InputFn, when non-nil, is called instead of prompting via the + // terminal. Used in tests to simulate interactive text input. + InputFn func(prompt, defaultValue string) (string, error) } // New creates a new Config with terminal-aware output and color support. diff --git a/internal/prompter/prompter.go b/internal/prompter/prompter.go new file mode 100644 index 0000000..f506d41 --- /dev/null +++ b/internal/prompter/prompter.go @@ -0,0 +1,236 @@ +// Package prompter provides interactive prompts using charm.land/huh/v2. +// +// This replaces the go-gh/v2/pkg/prompter (survey/v2-based) to avoid +// terminal scrolling issues in modern terminals. The API mirrors go-gh's +// prompter so call-sites only need an import-path swap. +// +// Modeled after cli/cli's internal/prompter/huh_prompter.go. +package prompter + +import ( + "bufio" + "errors" + "fmt" + "io" + "slices" + "strings" + + "charm.land/huh/v2" + "charm.land/lipgloss/v2" +) + +// ErrInterrupt is returned when the user cancels a prompt (e.g. Ctrl+C). +var ErrInterrupt = errors.New("prompt interrupted") + +// FileWriter provides a minimal writable interface for stdout/stderr. +type FileWriter interface { + io.Writer + Fd() uintptr +} + +// FileReader provides a minimal readable interface for stdin. +type FileReader interface { + io.Reader + Fd() uintptr +} + +var ( + cyanStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("6")) +) + +// surveyTheme returns a huh theme that visually matches the survey/v2 prompt +// style: no box border, green "?" prefix, inline layout. +func surveyTheme(isDark bool) *huh.Styles { + t := huh.ThemeBase(isDark) + + cyan := lipgloss.Color("6") + + // No border, no padding — survey prompts are flush left. + t.Focused.Base = lipgloss.NewStyle() + t.Focused.Card = t.Focused.Base + + // Title has no forced color so embedded ANSI (green "?") is preserved. + t.Focused.Title = lipgloss.NewStyle().Bold(true) + t.Focused.Description = lipgloss.NewStyle() + + // Select options. + t.Focused.SelectSelector = lipgloss.NewStyle().Foreground(cyan).SetString("> ") + t.Focused.Option = lipgloss.NewStyle() + t.Focused.NextIndicator = lipgloss.NewStyle().MarginLeft(1).SetString("↓") + t.Focused.PrevIndicator = lipgloss.NewStyle().MarginRight(1).SetString("↑") + + // Text input cursor/prompt. + t.Focused.TextInput.Cursor = lipgloss.NewStyle().Foreground(cyan) + t.Focused.TextInput.Prompt = lipgloss.NewStyle().Foreground(cyan) + t.Focused.TextInput.Placeholder = lipgloss.NewStyle().Foreground(lipgloss.Color("8")) + t.Focused.TextInput.Text = lipgloss.NewStyle().Foreground(cyan) + + // Confirm buttons — minimal style to match survey's (Y/n) look. + t.Focused.FocusedButton = lipgloss.NewStyle().Bold(true).Foreground(cyan). + Padding(0, 1) + t.Focused.BlurredButton = lipgloss.NewStyle(). + Padding(0, 1) + + // Blurred (non-focused) fields are identical but without border. + t.Blurred = t.Focused + t.Blurred.Base = lipgloss.NewStyle() + t.Blurred.Card = t.Blurred.Base + + t.FieldSeparator = lipgloss.NewStyle().SetString("\n") + + return t +} + +// Prompter provides interactive prompt methods backed by huh. +type Prompter struct { + stdin FileReader + stdout FileWriter + stderr FileWriter +} + +// New creates a Prompter that reads from stdin and writes to stdout/stderr. +func New(stdin FileReader, stdout FileWriter, stderr FileWriter) *Prompter { + return &Prompter{stdin: stdin, stdout: stdout, stderr: stderr} +} + +func (p *Prompter) newForm(groups ...*huh.Group) *huh.Form { + return huh.NewForm(groups...). + WithTheme(huh.ThemeFunc(surveyTheme)). + WithShowHelp(false). + WithInput(p.stdin). + WithOutput(p.stdout) +} + +func (p *Prompter) runForm(form *huh.Form) error { + err := form.Run() + if errors.Is(err, huh.ErrUserAborted) { + return ErrInterrupt + } + return err +} + +// printResult re-prints the prompt after huh clears its rendering, +// matching survey's behavior where the completed prompt stays visible. +func (p *Prompter) printResult(prompt, answer string) { + q := cyanStyle.Render("?") + if answer == "" { + fmt.Fprintf(p.stderr, "%s %s\n", q, prompt) + } else { + fmt.Fprintf(p.stderr, "%s %s %s\n", q, prompt, cyanStyle.Render(answer)) + } +} + +// surveyTitle prepends the cyan "?" icon to match survey/v2 prompt style. +func surveyTitle(prompt string) string { + q := cyanStyle.Render("?") + return q + " " + prompt +} + +// selectPageSize is the maximum number of visible options in a select prompt. +const selectPageSize = 20 + +// Select prompts the user to select an option from a list of options. +func (p *Prompter) Select(prompt, defaultValue string, options []string) (int, error) { + var result int + + if !slices.Contains(options, defaultValue) { + defaultValue = "" + } + + formOptions := make([]huh.Option[int], len(options)) + for i, o := range options { + if defaultValue == o { + result = i + } + formOptions[i] = huh.NewOption(o, i) + } + + form := p.newForm( + huh.NewGroup( + huh.NewSelect[int](). + Title(surveyTitle(prompt)). + Value(&result). + Options(formOptions...), + ), + ) + + err := p.runForm(form) + + // Clear residual select rendering — huh's bubbletea renderer may leave + // lines behind. Move cursor up past title + visible options, then clear. + visible := len(options) + if visible > selectPageSize { + visible = selectPageSize + } + lines := 1 + visible // 1 title + N options + fmt.Fprintf(p.stderr, "\033[%dA\033[J", lines) + + if err != nil { + p.printResult(prompt, "") + return result, err + } + if result >= 0 && result < len(options) { + p.printResult(prompt, options[result]) + } + return result, nil +} + +// Input prompts the user to input a single-line string. +func (p *Prompter) Input(prompt, defaultValue string) (string, error) { + result := defaultValue + form := p.newForm( + huh.NewGroup( + huh.NewInput(). + Title(surveyTitle(prompt)). + Prompt(" "). + Inline(true). + Value(&result), + ), + ) + + err := p.runForm(form) + p.printResult(prompt, result) + return result, err +} + +// Confirm prompts the user to confirm a yes/no question. +// Uses a simple line-based prompt matching survey/v2's (Y/n) format. +func (p *Prompter) Confirm(prompt string, defaultValue bool) (bool, error) { + hint := "(y/N)" + if defaultValue { + hint = "(Y/n)" + } + q := cyanStyle.Render("?") + fmt.Fprintf(p.stderr, "%s %s %s ", q, prompt, hint) + + reader := bufio.NewReader(p.stdin) + line, err := reader.ReadString('\n') + if err != nil { + // EOF or read error — treat as interrupt. + fmt.Fprintln(p.stderr) + return defaultValue, ErrInterrupt + } + + val := strings.TrimSpace(line) + var answer bool + switch strings.ToLower(val) { + case "y", "yes": + answer = true + case "n", "no": + answer = false + case "": + answer = defaultValue + default: + answer = defaultValue + } + + // Overwrite the prompt line with the final answer (survey Cleanup style). + answerText := "No" + if answer { + answerText = "Yes" + } + // Move up one line (ReadString echoed \n), rewrite, clear rest. + fmt.Fprintf(p.stderr, "\033[1A\r%s %s %s\033[K\n", q, prompt, cyanStyle.Render(answerText)) + + return answer, nil +}