diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-05-13 08:03:56 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2017-05-13 08:03:56 +0800 |
commit | ef7b9fb7d0cbcc2e381074f6be82e4791c41bdeb (patch) | |
tree | ca48cba0b535c6edaf9b4bc04d12d6f09ac79130 /cmd/puppeth/wizard.go | |
parent | b0d0fafd68f526ceed98e59a423b6470f2327a21 (diff) | |
download | dexon-ef7b9fb7d0cbcc2e381074f6be82e4791c41bdeb.tar.gz dexon-ef7b9fb7d0cbcc2e381074f6be82e4791c41bdeb.tar.zst dexon-ef7b9fb7d0cbcc2e381074f6be82e4791c41bdeb.zip |
cmd/puppeth: v4/v5 boot separation, signer gas configs (#14453)
Diffstat (limited to 'cmd/puppeth/wizard.go')
-rw-r--r-- | cmd/puppeth/wizard.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/cmd/puppeth/wizard.go b/cmd/puppeth/wizard.go index 9687d5e0d..51e64688e 100644 --- a/cmd/puppeth/wizard.go +++ b/cmd/puppeth/wizard.go @@ -162,6 +162,48 @@ func (w *wizard) readDefaultInt(def int) int { } } +// readFloat reads a single line from stdin, trimming if from spaces, enforcing it +// to parse into a float. +func (w *wizard) readFloat() float64 { + 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 == "" { + continue + } + val, err := strconv.ParseFloat(strings.TrimSpace(text), 64) + if err != nil { + log.Error("Invalid input, expected float", "err", err) + continue + } + return val + } +} + +// readDefaultFloat reads a single line from stdin, trimming if from spaces, enforcing +// it to parse into a float. If an empty line is entered, the default value is returned. +func (w *wizard) readDefaultFloat(def float64) float64 { + 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 def + } + val, err := strconv.ParseFloat(strings.TrimSpace(text), 64) + if err != nil { + log.Error("Invalid input, expected float", "err", err) + continue + } + return val + } +} + // 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 { |