Skip to content

Commit

Permalink
chore(text): use getInput for number pick deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Jguer committed Oct 27, 2021
1 parent f925b71 commit 44cf547
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions pkg/dep/depPool.go
@@ -1,7 +1,6 @@
package dep

import (
"bufio"
"context"
"fmt"
"os"
Expand Down Expand Up @@ -556,27 +555,20 @@ func providerMenu(dep string, providers providers, noConfirm bool) *query.Pkg {
return providers.Pkgs[0]
}

reader := bufio.NewReader(os.Stdin)

numberBuf, overflow, err := reader.ReadLine()
numberBuf, err := text.GetInput("", false)
if err != nil {
fmt.Fprintln(os.Stderr, err)

break
}

if overflow {
text.Errorln(gotext.Get("input too long"))
continue
}

if string(numberBuf) == "" {
if numberBuf == "" {
return providers.Pkgs[0]
}

num, err := strconv.Atoi(string(numberBuf))
num, err := strconv.Atoi(numberBuf)
if err != nil {
text.Errorln(gotext.Get("invalid number: %s", string(numberBuf)))
text.Errorln(gotext.Get("invalid number: %s", numberBuf))
continue
}

Expand Down

0 comments on commit 44cf547

Please sign in to comment.