@@ -77,12 +77,11 @@ func PrettyPrint(i any) string {
7777
7878var ErrPromptTerminated = errdefs .Cancelled (errors .New ("prompt terminated" ))
7979
80- // DisableInputEcho disables input echo on the provided io.ReadCloser .
80+ // DisableInputEcho disables input echo on the provided streams.In .
8181// This is useful when the user provides sensitive information like passwords.
8282// The function returns a restore function that should be called to restore the
8383// terminal state.
84- func DisableInputEcho (in io.ReadCloser ) (restore func () error , err error ) {
85- ins := streams .NewIn (in )
84+ func DisableInputEcho (ins * streams.In ) (restore func () error , err error ) {
8685 oldState , err := term .SaveState (ins .FD ())
8786 if err != nil {
8887 return nil , err
@@ -100,15 +99,12 @@ func DisableInputEcho(in io.ReadCloser) (restore func() error, err error) {
10099// When the prompt returns an error, the caller should propagate the error up
101100// the stack and close the io.Reader used for the prompt which will prevent the
102101// background goroutine from blocking indefinitely.
103- func PromptForInput (ctx context.Context , in io.ReadCloser , out io.Writer , message string ) (string , error ) {
102+ func PromptForInput (ctx context.Context , in io.Reader , out io.Writer , message string ) (string , error ) {
104103 _ , _ = fmt .Fprint (out , message )
105104
106- ins := streams .NewIn (in )
107-
108105 result := make (chan string )
109-
110106 go func () {
111- scanner := bufio .NewScanner (ins )
107+ scanner := bufio .NewScanner (in )
112108 if scanner .Scan () {
113109 result <- strings .TrimSpace (scanner .Text ())
114110 }
0 commit comments