mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
cmd/geth: improve prompt
This commit is contained in:
parent
a3991058be
commit
81bbc4f1c0
1 changed files with 11 additions and 3 deletions
|
|
@ -238,22 +238,30 @@ func removeFolder(dir string) {
|
||||||
// confirmAndRemoveDB prompts the user for a last confirmation and removes the
|
// confirmAndRemoveDB prompts the user for a last confirmation and removes the
|
||||||
// list of folders if accepted.
|
// list of folders if accepted.
|
||||||
func confirmAndRemoveDB(paths []string, kind string) {
|
func confirmAndRemoveDB(paths []string, kind string) {
|
||||||
confirm, err := prompt.Stdin.PromptConfirm(fmt.Sprintf("Remove %s (%s)?", kind, paths))
|
msg := fmt.Sprintf("Remove %s?\n", kind)
|
||||||
|
for _, path := range paths {
|
||||||
|
msg += fmt.Sprintf("\t- %s\n", path)
|
||||||
|
}
|
||||||
|
confirm, err := prompt.Stdin.PromptConfirm(msg)
|
||||||
switch {
|
switch {
|
||||||
case err != nil:
|
case err != nil:
|
||||||
utils.Fatalf("%v", err)
|
utils.Fatalf("%v", err)
|
||||||
case !confirm:
|
case !confirm:
|
||||||
log.Info("Database deletion skipped", "kind", kind, "paths", paths)
|
log.Info("Database deletion skipped", "kind", kind, "paths", paths)
|
||||||
default:
|
default:
|
||||||
start := time.Now()
|
var (
|
||||||
|
deleted []string
|
||||||
|
start = time.Now()
|
||||||
|
)
|
||||||
for _, path := range paths {
|
for _, path := range paths {
|
||||||
if common.FileExist(path) {
|
if common.FileExist(path) {
|
||||||
removeFolder(path)
|
removeFolder(path)
|
||||||
|
deleted = append(deleted, path)
|
||||||
} else {
|
} else {
|
||||||
log.Info("Folder is not existent", "path", path)
|
log.Info("Folder is not existent", "path", path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Info("Database successfully deleted", "kind", kind, "paths", paths, "elapsed", common.PrettyDuration(time.Since(start)))
|
log.Info("Database successfully deleted", "kind", kind, "paths", deleted, "elapsed", common.PrettyDuration(time.Since(start)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue