mirror of
https://github.com/tendermint/tendermint.git
synced 2026-06-09 07:42:38 +00:00
Generate account from seed
This commit is contained in:
17
common/os.go
17
common/os.go
@@ -1,10 +1,12 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
@@ -206,3 +208,18 @@ func Tempfile(prefix string) (*os.File, string) {
|
||||
}
|
||||
return file, file.Name()
|
||||
}
|
||||
|
||||
func Prompt(prompt string, defaultValue string) (string, error) {
|
||||
fmt.Print(prompt)
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
line, err := reader.ReadString('\n')
|
||||
if err != nil {
|
||||
return defaultValue, err
|
||||
} else {
|
||||
line = strings.TrimSpace(line)
|
||||
if line == "" {
|
||||
return defaultValue, nil
|
||||
}
|
||||
return line, nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user