mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: Disable raw using confirm prompt on Darwin (#926)
This caused cancel errors on prompt, but would have caused incorrect content in parameter values if it surfaced. Fixes #915.
This commit is contained in:
+3
-2
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/bgentry/speakeasy"
|
||||
"github.com/mattn/go-isatty"
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/xerrors"
|
||||
)
|
||||
|
||||
// PromptOptions supply a set of options to the prompt.
|
||||
@@ -48,7 +49,7 @@ func Prompt(cmd *cobra.Command, opts PromptOptions) (string, error) {
|
||||
if opts.Secret && valid && isatty.IsTerminal(inFile.Fd()) {
|
||||
line, err = speakeasy.Ask("")
|
||||
} else {
|
||||
if runtime.GOOS == "darwin" && valid {
|
||||
if !opts.IsConfirm && runtime.GOOS == "darwin" && valid {
|
||||
var restore func()
|
||||
restore, err = removeLineLengthLimit(int(inFile.Fd()))
|
||||
if err != nil {
|
||||
@@ -99,7 +100,7 @@ func Prompt(cmd *cobra.Command, opts PromptOptions) (string, error) {
|
||||
return "", err
|
||||
case line := <-lineCh:
|
||||
if opts.IsConfirm && line != "yes" && line != "y" {
|
||||
return line, Canceled
|
||||
return line, xerrors.Errorf("got %q: %w", line, Canceled)
|
||||
}
|
||||
if opts.Validate != nil {
|
||||
err := opts.Validate(line)
|
||||
|
||||
Reference in New Issue
Block a user