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:
Kyle Carberry
2022-04-08 11:25:19 -05:00
committed by GitHub
parent 0bf9dee7e3
commit cb5b228a21
+3 -2
View File
@@ -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)