Skip to content

Commit a3578ac

Browse files
authored
Merge pull request #2163 from onflow/cf/improve-account-readability
Improve account output readability
2 parents 3de10c9 + 277f681 commit a3578ac

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

internal/accounts/accounts.go

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/onflow/flow-go-sdk"
2727
"github.com/spf13/cobra"
2828

29+
"github.com/onflow/flow-cli/common/branding"
2930
"github.com/onflow/flow-cli/internal/command"
3031
"github.com/onflow/flow-cli/internal/util"
3132
)
@@ -95,46 +96,46 @@ func (r *accountResult) String() string {
9596
if r.Address.IsValid(flow.Testnet) {
9697
_, _ = fmt.Fprintf(
9798
writer,
98-
"If you would like to fund the account with 1000 FLOW tokens for testing,"+
99-
" visit %s\n\n",
100-
testnetFaucetURL(r.Address),
99+
"%s %s\n\n",
100+
branding.GrayStyle.Render("If you would like to fund the account with 1000 FLOW tokens for testing, visit"),
101+
branding.PurpleStyle.Render(testnetFaucetURL(r.Address)),
101102
)
102103
}
103104

104-
_, _ = fmt.Fprintf(writer, "Address\t 0x%s\n", r.Address)
105-
_, _ = fmt.Fprintf(writer, "Balance\t %s\n", cadence.UFix64(r.Balance))
105+
_, _ = fmt.Fprintf(writer, "%s\t %s\n", branding.GrayStyle.Render("Address"), branding.PurpleStyle.Render("0x"+r.Address.String()))
106+
_, _ = fmt.Fprintf(writer, "%s\t %s\n", branding.GrayStyle.Render("Balance"), branding.GreenStyle.Render(cadence.UFix64(r.Balance).String()))
106107

107-
_, _ = fmt.Fprintf(writer, "Keys\t %d\n", len(r.Keys))
108+
_, _ = fmt.Fprintf(writer, "%s\t %d\n", branding.GrayStyle.Render("Keys"), len(r.Keys))
108109

109110
for i, key := range r.Keys {
110-
_, _ = fmt.Fprintf(writer, "\nKey %d\tPublic Key\t %x\n", i, key.PublicKey.Encode())
111-
_, _ = fmt.Fprintf(writer, "\tWeight\t %d\n", key.Weight)
112-
_, _ = fmt.Fprintf(writer, "\tSignature Algorithm\t %s\n", key.SigAlgo)
113-
_, _ = fmt.Fprintf(writer, "\tHash Algorithm\t %s\n", key.HashAlgo)
114-
_, _ = fmt.Fprintf(writer, "\tRevoked \t %t\n", key.Revoked)
115-
_, _ = fmt.Fprintf(writer, "\tSequence Number \t %d\n", key.SequenceNumber)
116-
_, _ = fmt.Fprintf(writer, "\tIndex \t %d\n", key.Index)
111+
_, _ = fmt.Fprintf(writer, "\n%s %d\t%s\t %x\n", branding.GrayStyle.Render("Key"), i, branding.GrayStyle.Render("Public Key"), key.PublicKey.Encode())
112+
_, _ = fmt.Fprintf(writer, "\t%s\t %d\n", branding.GrayStyle.Render("Weight"), key.Weight)
113+
_, _ = fmt.Fprintf(writer, "\t%s\t %s\n", branding.GrayStyle.Render("Signature Algorithm"), key.SigAlgo)
114+
_, _ = fmt.Fprintf(writer, "\t%s\t %s\n", branding.GrayStyle.Render("Hash Algorithm"), key.HashAlgo)
115+
_, _ = fmt.Fprintf(writer, "\t%s \t %t\n", branding.GrayStyle.Render("Revoked"), key.Revoked)
116+
_, _ = fmt.Fprintf(writer, "\t%s \t %d\n", branding.GrayStyle.Render("Sequence Number"), key.SequenceNumber)
117+
_, _ = fmt.Fprintf(writer, "\t%s \t %d\n", branding.GrayStyle.Render("Index"), key.Index)
117118
_, _ = fmt.Fprintf(writer, "\n")
118119

119120
// only show up to 3 keys and then show label to expand more info
120121
if i == 3 && !command.ContainsFlag(r.include, "keys") {
121-
_, _ = fmt.Fprint(writer, "...keys minimized, use --include keys flag if you want to view all\n\n")
122+
_, _ = fmt.Fprint(writer, branding.GrayStyle.Render("...keys minimized, use --include keys flag if you want to view all\n\n"))
122123
break
123124
}
124125
}
125126

126-
_, _ = fmt.Fprintf(writer, "Contracts Deployed: %d\n", len(r.Contracts))
127+
_, _ = fmt.Fprintf(writer, "%s %d\n", branding.GrayStyle.Render("Contracts Deployed:"), len(r.Contracts))
127128
for name := range r.Contracts {
128-
_, _ = fmt.Fprintf(writer, "Contract: '%s'\n", name)
129+
_, _ = fmt.Fprintf(writer, "%s %s\n", branding.GrayStyle.Render("Contract:"), branding.PurpleStyle.Render("'"+name+"'"))
129130
}
130131

131132
if command.ContainsFlag(r.include, "contracts") {
132133
for name, code := range r.Contracts {
133-
_, _ = fmt.Fprintf(writer, "Contracts '%s':\n", name)
134+
_, _ = fmt.Fprintf(writer, "%s %s:\n", branding.GrayStyle.Render("Contracts"), branding.PurpleStyle.Render("'"+name+"'"))
134135
_, _ = fmt.Fprintln(writer, string(code))
135136
}
136137
} else {
137-
_, _ = fmt.Fprint(writer, "\n\nContracts (hidden, use --include contracts)")
138+
_, _ = fmt.Fprint(writer, "\n\n"+branding.GrayStyle.Render("Contracts (hidden, use --include contracts)"))
138139
}
139140

140141
_ = writer.Flush()

0 commit comments

Comments
 (0)