Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Aptimex committed Aug 23, 2024
1 parent f774b45 commit 9fd1b38
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,22 +178,23 @@ func (c statusCmdConfig) Run() {
api: %v
routes: %v
error: %v`, node.peerConfig.GetPublicKey().String()[:8], api, strings.Join(ips, ","), error_wrap(node.error, 80))))
error: %v`, node.peerConfig.GetPublicKey().String()[:8], api, strings.Join(ips, ","), errorWrap(node.error, 80))))
fmt.Fprintln(color.Output, WhiteBold(t))
}
}
}

func error_wrap(text string, lineWidth int) string {
func errorWrap(text string, lineWidth int) string {
words := strings.Fields(strings.TrimSpace(text))
if len(words) == 0 {
return text
}
wrapped := words[0]
spaceLeft := lineWidth - len(wrapped)
indent := len(" error: ")
for _, word := range words[1:] {
if len(word)+1 > spaceLeft {
wrapped += " \n " + word
wrapped += " \n" + strings.Repeat(" ", indent) + word
spaceLeft = lineWidth - len(word)
} else {
wrapped += " " + word
Expand Down

0 comments on commit 9fd1b38

Please sign in to comment.