mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 20:37:17 +00:00
Allow Multiple Selection For Exports (#6749)
* add changes * Merge branch 'master' into fixExports * last request * Merge branch 'fixExports' of https://github.com/prysmaticlabs/geth-sharding into fixExports
This commit is contained in:
parent
607d5fdf4e
commit
7861005990
@ -7,6 +7,7 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/logrusorgru/aurora"
|
||||
@ -80,21 +81,49 @@ func selectAccounts(cliCtx *cli.Context, accounts []string) ([]string, error) {
|
||||
}
|
||||
return enteredAccounts, nil
|
||||
}
|
||||
|
||||
prompt := promptui.SelectWithAdd{
|
||||
Label: "Select accounts to backup",
|
||||
Items: append(accounts, allAccountsText),
|
||||
templates := &promptui.SelectTemplates{
|
||||
Label: "{{ . }}",
|
||||
Active: "\U0001F336 {{ .Name | cyan }}",
|
||||
Inactive: " {{ .Name | cyan }}",
|
||||
Selected: "\U0001F336 {{ .Name | red | cyan }}",
|
||||
Details: `
|
||||
--------- Account ----------
|
||||
{{ "Name:" | faint }} {{ .Name }}`,
|
||||
}
|
||||
|
||||
_, result, err := prompt.Run()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var result string
|
||||
var err error
|
||||
exit := "Exit Account Selection"
|
||||
results := []string{}
|
||||
au := aurora.NewAurora(true)
|
||||
// Alphabetical Sort of accounts.
|
||||
sort.Strings(accounts)
|
||||
|
||||
for result != exit {
|
||||
prompt := promptui.Select{
|
||||
Label: "Select accounts to backup",
|
||||
HideSelected: true,
|
||||
Items: append([]string{exit, allAccountsText}, accounts...),
|
||||
Templates: templates,
|
||||
}
|
||||
|
||||
_, result, err = prompt.Run()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if result == exit {
|
||||
fmt.Printf("%s\n", au.BrightRed("Exiting Selection").Bold())
|
||||
return results, nil
|
||||
}
|
||||
if result == allAccountsText {
|
||||
fmt.Printf("%s\n", au.BrightRed("[Selected all accounts]").Bold())
|
||||
return accounts, nil
|
||||
}
|
||||
results = append(results, result)
|
||||
fmt.Printf("%s %s\n", au.BrightRed("[Selected Account Name]").Bold(), result)
|
||||
}
|
||||
|
||||
if result == allAccountsText {
|
||||
return accounts, nil
|
||||
}
|
||||
return []string{result}, nil
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func (w *Wallet) zipAccounts(accounts []string, targetPath string) error {
|
||||
@ -103,6 +132,9 @@ func (w *Wallet) zipAccounts(accounts []string, targetPath string) error {
|
||||
if err := os.MkdirAll(targetPath, params.BeaconIoConfig().ReadWriteExecutePermissions); err != nil {
|
||||
return errors.Wrap(err, "could not create target folder")
|
||||
}
|
||||
if fileExists(archivePath) {
|
||||
return errors.Errorf("Zip file already exists in directory: %s", archivePath)
|
||||
}
|
||||
zipfile, err := os.Create(archivePath)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not create zip file")
|
||||
|
Loading…
Reference in New Issue
Block a user