From a4d325a16d4fd60adb7477ee183fe1b149dad392 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 17 Dec 2024 13:58:19 -0300 Subject: [PATCH] fix: rebase on main --- confirm/command.go | 2 +- internal/stdin/stdin.go | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/confirm/command.go b/confirm/command.go index ec7ab6870..103fbad16 100644 --- a/confirm/command.go +++ b/confirm/command.go @@ -16,7 +16,7 @@ var errNotConfirmed = errors.New("not confirmed") // Run provides a shell script interface for prompting a user to confirm an // action with an affirmative or negative answer. func (o Options) Run() error { - line, err := stdin.ReadLine() + line, err := stdin.Read(stdin.SingleLine(true)) if err == nil { switch line { case "yes", "y": diff --git a/internal/stdin/stdin.go b/internal/stdin/stdin.go index 5ddaa4dd9..42b016285 100644 --- a/internal/stdin/stdin.go +++ b/internal/stdin/stdin.go @@ -2,7 +2,6 @@ package stdin import ( "bufio" - "errors" "fmt" "io" "os" @@ -11,8 +10,6 @@ import ( "github.com/charmbracelet/x/ansi" ) -var ErrEmpty = errors.New("stdin is empty") - type options struct { ansiStrip bool singleLine bool @@ -38,7 +35,7 @@ func SingleLine(b bool) Option { // Read reads input from an stdin pipe. func Read(opts ...Option) (string, error) { if IsEmpty() { - return "", ErrEmpty + return "", fmt.Errorf("stdin is empty") } options := options{}