diff --git a/ecs/wait.go b/ecs/wait.go index baedda0b..e0080062 100644 --- a/ecs/wait.go +++ b/ecs/wait.go @@ -74,8 +74,7 @@ func (b *ecsAPIService) WaitStackCompletion(ctx context.Context, name string, op knownEvents[*event.EventId] = struct{}{} resource := aws.StringValue(event.LogicalResourceId) - reason := shortenMessage( - aws.StringValue(event.ResourceStatusReason)) + reason := aws.StringValue(event.ResourceStatusReason) status := aws.StringValue(event.ResourceStatus) progressStatus := progress.Working @@ -116,21 +115,13 @@ func (b *ecsAPIService) WaitStackCompletion(ctx context.Context, name string, op } stackErr = err operation = stackDelete - reason := shortenMessage(err.Error()) w.Event(progress.Event{ ID: name, Status: progress.Error, - StatusText: reason, + StatusText: err.Error(), }) } } return stackErr } - -func shortenMessage(message string) string { - if len(message) < 30 { - return message - } - return message[:30] + "..." -} diff --git a/progress/tty.go b/progress/tty.go index 1da062ae..9a9d70e1 100644 --- a/progress/tty.go +++ b/progress/tty.go @@ -146,12 +146,19 @@ func lineText(event Event, terminalWidth, statusPadding int, color bool) string if padding < 0 { padding = 0 } + // calculate the max length for the status text, on errors it + // is 2-3 lines long and breaks the line formating + maxStatusLen := terminalWidth - textLen - statusPadding - 15 + status := event.StatusText + if len(status) > maxStatusLen { + status = status[:maxStatusLen] + "..." + } text := fmt.Sprintf(" %s %s %s%s %s", event.spinner.String(), event.ID, event.Text, strings.Repeat(" ", padding), - event.StatusText, + status, ) timer := fmt.Sprintf("%.1fs\n", elapsed) o := align(text, timer, terminalWidth)