yay/pkg/text/input.go
Jo 0bf4c2e502
feat(new_install): show (#1915)
* show new packages in upgrade form if they exist

* refactor up select

* remove unused graph parts

* readd len

* Complete upgrade graphing

* Extract to upgrade pkg

* remove unused dep method

* remove uneeded dep

* cleanup method

* specify io Reader for testing

* use specified input vector

* fix non-active devel

* test base cases

* add devel test cases

* add range tests

* add logger struct

* use logger struct in upgrade

* follow golangci recommendations

* update deps

* update golangci
2023-02-17 19:01:26 +00:00

34 lines
565 B
Go

package text
import (
"bufio"
"fmt"
"io"
)
func (l *Logger) GetInput(defaultValue string, noConfirm bool) (string, error) {
Info()
if defaultValue != "" || noConfirm {
fmt.Println(defaultValue)
return defaultValue, nil
}
reader := bufio.NewReader(l.r)
buf, overflow, err := reader.ReadLine()
if err != nil {
return "", err
}
if overflow {
return "", ErrInputOverflow{}
}
return string(buf), nil
}
func GetInput(r io.Reader, defaultValue string, noConfirm bool) (string, error) {
return globalLogger.GetInput(defaultValue, noConfirm)
}