chore(alpm): use text.getinput for ialpm

This commit is contained in:
jguer 2021-10-16 22:42:56 +02:00 committed by J Guerreiro
parent 9eb73899fe
commit 57a9630054

View file

@ -1,7 +1,6 @@
package ialpm package ialpm
import ( import (
"bufio"
"errors" "errors"
"fmt" "fmt"
"os" "os"
@ -191,28 +190,19 @@ func (ae *AlpmExecutor) questionCallback() func(question alpm.QuestionAny) {
break break
} }
reader := bufio.NewReader(os.Stdin) numberBuf, err := text.GetInput("", false)
numberBuf, overflow, err := reader.ReadLine()
if err != nil { if err != nil {
text.Errorln(err) text.Errorln(err)
break break
} }
if overflow { if numberBuf == "" {
text.Errorln(gotext.Get(" Input too long"))
continue
}
if string(numberBuf) == "" {
break break
} }
num, err := strconv.Atoi(string(numberBuf)) num, err := strconv.Atoi(numberBuf)
if err != nil { if err != nil {
text.Errorln(gotext.Get("invalid number: %s", string(numberBuf))) text.Errorln(gotext.Get("invalid number: %s", numberBuf))
continue continue
} }