Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

Commit

Permalink
cmd/puppeth: remove wrapping loop in single reads
Browse files Browse the repository at this point in the history
  • Loading branch information
karalabe committed Aug 4, 2017
1 parent 0cc9b87 commit 455fcc8
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions cmd/puppeth/wizard.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,15 @@ func (w *wizard) readString() string {
// readDefaultString reads a single line from stdin, trimming if from spaces. If
// an empty line is entered, the default value is returned.
func (w *wizard) readDefaultString(def string) string {
for {
fmt.Printf("> ")
text, err := w.in.ReadString('\n')
if err != nil {
log.Crit("Failed to read user input", "err", err)
}
if text = strings.TrimSpace(text); text != "" {
return text
}
return def
fmt.Printf("> ")
text, err := w.in.ReadString('\n')
if err != nil {
log.Crit("Failed to read user input", "err", err)
}
if text = strings.TrimSpace(text); text != "" {
return text
}
return def
}

// readInt reads a single line from stdin, trimming if from spaces, enforcing it
Expand Down Expand Up @@ -207,15 +205,13 @@ func (w *wizard) readDefaultFloat(def float64) float64 {
// readPassword reads a single line from stdin, trimming it from the trailing new
// line and returns it. The input will not be echoed.
func (w *wizard) readPassword() string {
for {
fmt.Printf("> ")
text, err := terminal.ReadPassword(int(syscall.Stdin))
if err != nil {
log.Crit("Failed to read password", "err", err)
}
fmt.Println()
return string(text)
fmt.Printf("> ")
text, err := terminal.ReadPassword(int(syscall.Stdin))
if err != nil {
log.Crit("Failed to read password", "err", err)
}
fmt.Println()
return string(text)
}

// readAddress reads a single line from stdin, trimming if from spaces and converts
Expand Down

0 comments on commit 455fcc8

Please sign in to comment.