mirror of
https://github.com/Jguer/yay.git
synced 2024-11-07 09:37:22 +01:00
0bf4c2e502
* 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
34 lines
565 B
Go
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)
|
|
}
|