diff options
author | Martin Holst Swende <martin@swende.se> | 2018-11-25 06:22:25 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-12-03 18:34:41 +0800 |
commit | 8698fbabf6c7811e8eec6e84512510e9c9a4eb45 (patch) | |
tree | bfd4570f18e332e2d51a140aa331ab9507bd2983 /cmd/puppeth/wizard.go | |
parent | a3fd415c0f983cae35c329d97e0b6707561daef6 (diff) | |
download | dexon-8698fbabf6c7811e8eec6e84512510e9c9a4eb45.tar dexon-8698fbabf6c7811e8eec6e84512510e9c9a4eb45.tar.gz dexon-8698fbabf6c7811e8eec6e84512510e9c9a4eb45.tar.bz2 dexon-8698fbabf6c7811e8eec6e84512510e9c9a4eb45.tar.lz dexon-8698fbabf6c7811e8eec6e84512510e9c9a4eb45.tar.xz dexon-8698fbabf6c7811e8eec6e84512510e9c9a4eb45.tar.zst dexon-8698fbabf6c7811e8eec6e84512510e9c9a4eb45.zip |
cmd/puppeth: implement chainspec converters
Diffstat (limited to 'cmd/puppeth/wizard.go')
-rw-r--r-- | cmd/puppeth/wizard.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/cmd/puppeth/wizard.go b/cmd/puppeth/wizard.go index b88a61de7..42fc125e5 100644 --- a/cmd/puppeth/wizard.go +++ b/cmd/puppeth/wizard.go @@ -104,6 +104,28 @@ func (w *wizard) readString() string { } } +// readYesNo reads a yes or no from stdin, returning boolean true for yes +func (w *wizard) readYesNo(def bool) bool { + for { + fmt.Printf("> ") + text, err := w.in.ReadString('\n') + if err != nil { + log.Crit("Failed to read user input", "err", err) + } + text = strings.ToLower(strings.TrimSpace(text)) + if text == "y" || text == "yes" { + return true + } + if text == "n" || text == "no" { + return false + } + if len(text) == 0 { + return def + } + fmt.Println("Valid answers: y, yes, n, no or leave empty for default") + } +} + // 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 { |