30
30
MultiTaskMsgWaitingStyle = MultiTaskMsgSuccessStyle .Copy ().
31
31
Foreground (lipgloss.AdaptiveColor {Light : "#2B53AF" , Dark : "#37B9FF" })
32
32
33
+ MultiTaskMsgWarningStyle = MultiTaskMsgSuccessStyle .Copy ().
34
+ Foreground (lipgloss.AdaptiveColor {Light : "#FF9A0D" , Dark : "#F8CA61" })
35
+
33
36
MultiTaskSpinner = spinner.Model {
34
37
Style : lipgloss .NewStyle ().Foreground (lipgloss.AdaptiveColor {Light : "#FF9A0D" , Dark : "#F8CA61" }),
35
38
Spinner : spinner.Spinner {
@@ -67,6 +70,14 @@ type Task struct {
67
70
err error
68
71
}
69
72
73
+ type WarnErr struct {
74
+ Message string
75
+ }
76
+
77
+ func (e WarnErr ) Error () string {
78
+ return e .Message
79
+ }
80
+
70
81
type MultiTaskModel struct {
71
82
Tasks []Task
72
83
Spinner spinner.Model
@@ -77,6 +88,7 @@ type MultiTaskModel struct {
77
88
MsgSuccessStyle lipgloss.Style
78
89
MsgFailedStyle lipgloss.Style
79
90
MsgWaitingStyle lipgloss.Style
91
+ MsgWarningStyle lipgloss.Style
80
92
81
93
index int
82
94
}
@@ -95,6 +107,7 @@ func NewMultiTaskModelWithTasks(tasks []Task) MultiTaskModel {
95
107
MsgSuccessStyle : MultiTaskMsgSuccessStyle ,
96
108
MsgFailedStyle : MultiTaskMsgFailedStyle ,
97
109
MsgWaitingStyle : MultiTaskMsgWaitingStyle ,
110
+ MsgWarningStyle : MultiTaskMsgWarningStyle ,
98
111
}
99
112
}
100
113
@@ -119,7 +132,9 @@ func (m MultiTaskModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
119
132
}
120
133
case TaskDoneMsg :
121
134
if m .Tasks [m .index ].err != nil {
122
- return m , tea .Quit
135
+ if _ , ok := m .Tasks [m .index ].err .(WarnErr ); ! ok {
136
+ return m , tea .Quit
137
+ }
123
138
}
124
139
125
140
m .index ++
@@ -147,7 +162,11 @@ func (m MultiTaskModel) View() string {
147
162
view = lipgloss .JoinVertical (lipgloss .Left , view , m .Spinner .View ()+ " " + m .MsgWaitingStyle .Render (task .Title ))
148
163
}
149
164
} else {
150
- view = lipgloss .JoinVertical (lipgloss .Left , view , m .MsgFailedStyle .Render ("[ ✗ ] " + task .err .Error ()))
165
+ if _ , ok := task .err .(WarnErr ); ok {
166
+ view = lipgloss .JoinVertical (lipgloss .Left , view , m .MsgWarningStyle .Render ("[ ≡ ] " + task .err .Error ()))
167
+ } else {
168
+ view = lipgloss .JoinVertical (lipgloss .Left , view , m .MsgFailedStyle .Render ("[ ✗ ] " + task .err .Error ()))
169
+ }
151
170
}
152
171
153
172
}
0 commit comments