Skip to content

Commit

Permalink
cmd/clef: only print first N accounts on startup (ethereum#26128)
Browse files Browse the repository at this point in the history
PR ethereum#26082 added account listing to OnSignerStartup but did not consider the case where a user has a large number of accounts which would be annoying to display.

This PR updates showAccounts() so that if there are more than 20 accounts available the user sees the first 20 displayed in the console followed by: First 20 accounts listed (N more available).

Co-authored-by: Martin Holst Swende <martin@swende.se>
  • Loading branch information
2 people authored and shekhirin committed Jun 6, 2023
1 parent c564c89 commit a847b78
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion signer/core/cliui.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,17 @@ func (ui *CommandlineUI) showAccounts() {
fmt.Print("No accounts found\n")
return
}
var msg string
var out = new(strings.Builder)
if limit := 20; len(accounts) > limit {
msg = fmt.Sprintf("\nFirst %d accounts listed (%d more available).\n", limit, len(accounts)-limit)
accounts = accounts[:limit]
}
fmt.Fprint(out, "\n------- Available accounts -------\n")
for i, account := range accounts {
fmt.Fprintf(out, "%d. %s at %s\n", i, account.Address, account.URL)
}
fmt.Print(out.String())
fmt.Print(out.String(), msg)
}

func (ui *CommandlineUI) OnSignerStartup(info StartupInfo) {
Expand Down

0 comments on commit a847b78

Please sign in to comment.