Skip to content

Commit 1aa2f2e

Browse files
gtsiolissilv-io
andauthored
Use checkmark for success message (#113)
Co-authored-by: Silvio Vasiljevic <[email protected]>
1 parent 380b5bd commit 1aa2f2e

File tree

8 files changed

+28
-17
lines changed

8 files changed

+28
-17
lines changed

internal/output/plain_format.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ func formatStatusLine(e ContainerStatusEvent) (string, bool) {
4949
return "Waiting for LocalStack to be ready...", true
5050
case "ready":
5151
if e.Detail != "" {
52-
return fmt.Sprintf("LocalStack ready (%s)", e.Detail), true
52+
return fmt.Sprintf("%s LocalStack ready (%s)", SuccessMarker(), e.Detail), true
5353
}
54-
return "LocalStack ready", true
54+
return SuccessMarker() + " LocalStack ready", true
5555
default:
5656
if e.Detail != "" {
5757
return fmt.Sprintf("LocalStack: %s (%s)", e.Phase, e.Detail), true
@@ -116,7 +116,7 @@ func formatAuthEvent(e AuthEvent) string {
116116
func formatMessageEvent(e MessageEvent) string {
117117
switch e.Severity {
118118
case SeveritySuccess:
119-
return "> Success: " + e.Text
119+
return SuccessMarker() + " " + e.Text
120120
case SeverityNote:
121121
return "> Note: " + e.Text
122122
case SeverityWarning:
@@ -151,7 +151,7 @@ func formatErrorEvent(e ErrorEvent) string {
151151

152152
func formatInstanceInfo(e InstanceInfoEvent) string {
153153
var sb strings.Builder
154-
sb.WriteString("✓ " + e.EmulatorName + " is running (" + e.Host + ")")
154+
sb.WriteString(SuccessMarker() + " " + e.EmulatorName + " is running (" + e.Host + ")")
155155
var meta []string
156156
if e.Uptime > 0 {
157157
meta = append(meta, "UPTIME: "+formatUptime(e.Uptime))

internal/output/plain_format_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func TestFormatEventLine(t *testing.T) {
2424
{
2525
name: "message event success",
2626
event: MessageEvent{Severity: SeveritySuccess, Text: "done"},
27-
want: "> Success: done",
27+
want: SuccessMarker() + " done",
2828
wantOK: true,
2929
},
3030
{
@@ -60,7 +60,7 @@ func TestFormatEventLine(t *testing.T) {
6060
{
6161
name: "status ready with detail",
6262
event: ContainerStatusEvent{Phase: "ready", Container: "localstack-aws", Detail: "abc123"},
63-
want: "LocalStack ready (abc123)",
63+
want: SuccessMarker() + " LocalStack ready (abc123)",
6464
wantOK: true,
6565
},
6666
{
@@ -120,7 +120,7 @@ func TestFormatEventLine(t *testing.T) {
120120
ContainerName: "localstack-aws",
121121
Uptime: 4*time.Minute + 23*time.Second,
122122
},
123-
want: "✓ LocalStack AWS Emulator is running (localhost.localstack.cloud:4566)\n UPTIME: 4m 23s · CONTAINER: localstack-aws · VERSION: 4.14.1",
123+
want: SuccessMarker() + " LocalStack AWS Emulator is running (localhost.localstack.cloud:4566)\n UPTIME: 4m 23s · CONTAINER: localstack-aws · VERSION: 4.14.1",
124124
wantOK: true,
125125
},
126126
{
@@ -129,7 +129,7 @@ func TestFormatEventLine(t *testing.T) {
129129
EmulatorName: "LocalStack AWS Emulator",
130130
Host: "127.0.0.1:4566",
131131
},
132-
want: "✓ LocalStack AWS Emulator is running (127.0.0.1:4566)",
132+
want: SuccessMarker() + " LocalStack AWS Emulator is running (127.0.0.1:4566)",
133133
wantOK: true,
134134
},
135135
{
@@ -237,4 +237,3 @@ func TestFormatTableWidth(t *testing.T) {
237237
}
238238
})
239239
}
240-

internal/output/plain_sink_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ func TestPlainSink_EmitsStatusEvent(t *testing.T) {
6161
{
6262
name: "ready phase with detail",
6363
event: ContainerStatusEvent{Phase: "ready", Container: "localstack-aws", Detail: "abc123"},
64-
expected: "LocalStack ready (abc123)\n",
64+
expected: fmt.Sprintf("%s LocalStack ready (abc123)\n", SuccessMarker()),
6565
},
6666
{
6767
name: "ready phase without detail",
6868
event: ContainerStatusEvent{Phase: "ready", Container: "localstack-aws"},
69-
expected: "LocalStack ready\n",
69+
expected: fmt.Sprintf("%s LocalStack ready\n", SuccessMarker()),
7070
},
7171
{
7272
name: "unknown phase with detail",
@@ -163,7 +163,7 @@ func TestPlainSink_EmitsInstanceInfoEvent(t *testing.T) {
163163
Uptime: 4*time.Minute + 23*time.Second,
164164
})
165165

166-
expected := "✓ LocalStack AWS Emulator is running (localhost.localstack.cloud:4566)\n UPTIME: 4m 23s · CONTAINER: localstack-aws · VERSION: 4.14.1\n"
166+
expected := SuccessMarker() + " LocalStack AWS Emulator is running (localhost.localstack.cloud:4566)\n UPTIME: 4m 23s · CONTAINER: localstack-aws · VERSION: 4.14.1\n"
167167
assert.Equal(t, expected, out.String())
168168
assert.NoError(t, sink.Err())
169169
})
@@ -177,7 +177,7 @@ func TestPlainSink_EmitsInstanceInfoEvent(t *testing.T) {
177177
Host: "127.0.0.1:4566",
178178
})
179179

180-
expected := "✓ LocalStack AWS Emulator is running (127.0.0.1:4566)\n"
180+
expected := SuccessMarker() + " LocalStack AWS Emulator is running (127.0.0.1:4566)\n"
181181
assert.Equal(t, expected, out.String())
182182
assert.NoError(t, sink.Err())
183183
})

internal/output/symbols.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package output
2+
3+
func SuccessMarker() string {
4+
return "✔︎"
5+
}

internal/ui/app.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ func (a App) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
182182
a.pullProgress = a.pullProgress.Hide()
183183
}
184184
if line, ok := output.FormatEventLine(msg); ok {
185+
if msg.Phase == "ready" {
186+
line = strings.Replace(line, output.SuccessMarker(), styles.Success.Render(output.SuccessMarker()), 1)
187+
}
185188
a.lines = appendLine(a.lines, styledLine{text: line})
186189
}
187190
return a, nil

internal/ui/app_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func TestAppMessageEventRendering(t *testing.T) {
176176
if len(app.lines) != 1 {
177177
t.Fatalf("expected 1 line, got %d", len(app.lines))
178178
}
179-
if !strings.Contains(app.lines[0].text, "Success:") || !strings.Contains(app.lines[0].text, "Done") {
179+
if !strings.Contains(app.lines[0].text, output.SuccessMarker()) || !strings.Contains(app.lines[0].text, "Done") {
180180
t.Fatalf("expected rendered success message, got: %q", app.lines[0].text)
181181
}
182182
}

internal/ui/components/message.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ func messagePrefix(e output.MessageEvent) (string, string) {
4545
prefix := styles.Secondary.Render("> ")
4646
switch e.Severity {
4747
case output.SeveritySuccess:
48-
return "> Success:", prefix + styles.Success.Render("Success:")
48+
checkmark := output.SuccessMarker()
49+
return checkmark, styles.Success.Render(checkmark)
4950
case output.SeverityNote:
5051
return "> Note:", prefix + styles.Note.Render("Note:")
5152
case output.SeverityWarning:

internal/ui/styles/styles.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package styles
22

3-
import "github.com/charmbracelet/lipgloss"
3+
import (
4+
"github.com/charmbracelet/lipgloss"
5+
)
46

57
const (
68
NimboDarkColor = "#3F51C7"
79
NimboMidColor = "#5E6AD2"
810
NimboLightColor = "#7E88EC"
11+
SuccessColor = "#B7C95C"
912
)
1013

1114
var (
@@ -39,7 +42,7 @@ var (
3942

4043
// Message severity styles
4144
Success = lipgloss.NewStyle().
42-
Foreground(lipgloss.Color("42"))
45+
Foreground(lipgloss.Color(SuccessColor))
4346

4447
Note = lipgloss.NewStyle().
4548
Foreground(lipgloss.Color("33"))

0 commit comments

Comments
 (0)