Unverified Commit 6685f884 authored by Joseph Cook's avatar Joseph Cook Committed by GitHub

cmd/clef: only print first N accounts on startup (#26128)

PR #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: 's avatarMartin Holst Swende <martin@swende.se>
parent ee9ff064
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment