Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ google/uuid - https://github.com/google/uuid
Copyright (c) 2009,2014 Google Inc. All rights reserved.
License - https://github.com/google/uuid/blob/master/LICENSE

manifoldco/promptui - https://github.com/manifoldco/promptui
Copyright (c) 2017, Arigato Machine Inc. All rights reserved.
License - https://github.com/manifoldco/promptui/blob/master/LICENSE.md

hexops/gotextdiff - https://github.com/hexops/gotextdiff
Copyright (c) 2009 The Go Authors. All rights reserved.
License - https://github.com/hexops/gotextdiff/blob/main/LICENSE
Expand Down
2 changes: 1 addition & 1 deletion experimental/ssh/internal/setup/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func TestSetup_PromptsForClusterWhenNotProvided(t *testing.T) {
configPath := filepath.Join(tmpDir, "ssh_config")

// Replace the cluster picker with a stub returning a fixed ID. This lets the
// test exercise the empty-ClusterID path of Setup without driving promptui.
// test exercise the empty-ClusterID path of Setup without prompting.
origPrompt := clusterSelectionPrompt
t.Cleanup(func() { clusterSelectionPrompt = origPrompt })
promptCalled := false
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ require (
github.com/hashicorp/terraform-json v0.27.2 // MPL-2.0
github.com/hexops/gotextdiff v1.0.3 // BSD-3-Clause
github.com/jackc/pgx/v5 v5.9.2 // MIT
github.com/manifoldco/promptui v0.9.0 // BSD-3-Clause
github.com/mattn/go-isatty v0.0.21 // MIT
github.com/palantir/pkg/yamlpatch v1.5.0 // BSD-3-Clause
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // BSD-2-Clause
Expand Down Expand Up @@ -58,7 +57,6 @@ require (
github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 // indirect
github.com/charmbracelet/x/term v0.2.2 // indirect
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
github.com/clipperhouse/displaywidth v0.9.0 // indirect
github.com/clipperhouse/stringish v0.1.1 // indirect
github.com/clipperhouse/uax29/v2 v2.5.0 // indirect
Expand Down
9 changes: 0 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ 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.2 h1:Pqmu4TEJ8KeA9uSkISKMU3f+C1F6OGBn8ABuGlqCbtI=
github.com/charmbracelet/x/xpty v0.1.2/go.mod h1:XK2Z0id5rtLWcpeNiMYBccNNBrP2IJnzHI0Lq13Xzq4=
github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
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=
Expand Down Expand Up @@ -162,8 +156,6 @@ 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/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA=
github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg=
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.21 h1:xYae+lCNBP7QuW4PUnNG61ffM4hVIfm+zUzDuSzYLGs=
Expand Down Expand Up @@ -261,7 +253,6 @@ golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs=
golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q=
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
Expand Down
11 changes: 4 additions & 7 deletions libs/cmdio/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,10 @@ func (c Capabilities) SupportsPager() bool {
return c.SupportsPrompt() && c.stdoutIsTTY
}

// detectGitBash returns true if running in Git Bash on Windows (has broken promptui support).
// We do not allow prompting in Git Bash on Windows.
// Likely due to fact that Git Bash does not correctly support ANSI escape sequences,
// we cannot use promptui package there.
// See known issues:
// - https://github.com/manifoldco/promptui/issues/208
// - https://github.com/chzyer/readline/issues/191
// detectGitBash returns true if running in Git Bash on Windows. We disable
// prompting there because Git Bash's ANSI handling has historically broken
// the line editor; the flag is kept so SupportsPrompt can gate on it and
// callers don't accidentally render a garbled UI.
func detectGitBash(ctx context.Context) bool {
// Check if the MSYSTEM environment variable is set to "MINGW64"
msystem := env.Get(ctx, "MSYSTEM")
Expand Down
2 changes: 2 additions & 0 deletions libs/cmdio/color.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import (
const (
ansiReset = "\x1b[0m"
ansiBold = "\x1b[1m"
ansiFaint = "\x1b[2m"
ansiItalic = "\x1b[3m"
ansiUnderline = "\x1b[4m"
ansiRed = "\x1b[31m"
ansiGreen = "\x1b[32m"
ansiYellow = "\x1b[33m"
Expand Down
41 changes: 19 additions & 22 deletions libs/cmdio/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,33 @@ package cmdio

import (
"context"
"errors"
"io"
"os"
"strings"
"sync"

tea "github.com/charmbracelet/bubbletea"
"github.com/databricks/cli/libs/flags"
)

// errCtrlC is returned when the user cancels a TUI prompt with Ctrl+C. The
// "^C" string matches the historical wire format; goldens depend on it.
var errCtrlC = errors.New("^C")

// runTUI runs a tea.Program through cmdIO's tea program slot so spinners and
// pagers can't fight a prompt for the terminal. Blocks until the model quits.
func (c *cmdIO) runTUI(m tea.Model) (tea.Model, error) {
p := tea.NewProgram(m,
tea.WithInput(c.in),
tea.WithOutput(c.err),
// Ctrl+C is delivered as a key event so the model can return errCtrlC.
tea.WithoutSignalHandler(),
)
c.acquireTeaProgram(p)
defer c.releaseTeaProgram()
return p.Run()
}

// cmdIO is the private instance, that is not supposed to be accessed
// outside of `cmdio` package. Use the public package-level functions
// to access the inner state.
Expand Down Expand Up @@ -69,27 +87,6 @@ func GetInteractiveMode(ctx context.Context) InteractiveMode {
return c.capabilities.InteractiveMode()
}

// promptStdin returns the stdin reader for use with promptui.
// If the reader is os.Stdin, it returns nil to let the underlying readline
// library use its platform-specific default. On Windows, this is critical
// because readline's default uses ReadConsoleInputW to read arrow keys
// as virtual key events. Passing a wrapped os.Stdin would bypass this
// and break arrow key navigation in selection prompts.
func (c *cmdIO) promptStdin() io.ReadCloser {
if c.in == os.Stdin {
return nil
}
return io.NopCloser(c.in)
}

type nopWriteCloser struct {
io.Writer
}

func (nopWriteCloser) Close() error {
return nil
}

// NewSpinner creates a new spinner for displaying progress indicators.
// The returned spinner should be closed when done to release resources.
//
Expand Down
Loading