2
2
package library
3
3
4
4
import (
5
+ "os"
5
6
"path/filepath"
6
7
7
8
"github.com/atotto/clipboard"
@@ -117,17 +118,17 @@ func (l *Library) updateWsPane(msg tea.Msg) (viewport.Model, tea.Cmd) {
117
118
}
118
119
case "o" :
119
120
if curWsCfg == nil {
120
- l .SetNotice ("no workspace selected" , styles .NoticeLevelError )
121
+ l .SetNotice ("no workspace selected" , styles .OutputLevelError )
121
122
break
122
123
}
123
124
124
125
if err := open .Open (curWsCfg .Location (), false ); err != nil {
125
126
l .ctx .Logger .Error (err , "unable to open workspace" )
126
- l .SetNotice ("unable to open workspace" , styles .NoticeLevelError )
127
+ l .SetNotice ("unable to open workspace" , styles .OutputLevelError )
127
128
}
128
129
case "e" :
129
130
if curWsCfg == nil {
130
- l .SetNotice ("no workspace selected" , styles .NoticeLevelError )
131
+ l .SetNotice ("no workspace selected" , styles .OutputLevelError )
131
132
break
132
133
}
133
134
@@ -136,47 +137,47 @@ func (l *Library) updateWsPane(msg tea.Msg) (viewport.Model, tea.Cmd) {
136
137
l .ctx .StdIn (), l .ctx .StdOut (),
137
138
); err != nil {
138
139
l .ctx .Logger .Error (err , "unable to open workspace in editor" )
139
- l .SetNotice ("unable to open workspace in editor" , styles .NoticeLevelError )
140
+ l .SetNotice ("unable to open workspace in editor" , styles .OutputLevelError )
140
141
}
141
142
case "s" :
142
143
if curWsCfg == nil {
143
- l .SetNotice ("no workspace selected" , styles .NoticeLevelError )
144
+ l .SetNotice ("no workspace selected" , styles .OutputLevelError )
144
145
break
145
146
}
146
147
147
148
curCfg , err := filesystem .LoadConfig ()
148
149
if err != nil {
149
150
l .ctx .Logger .Error (err , "unable to load user config" )
150
- l .SetNotice ("unable to load user config" , styles .NoticeLevelError )
151
+ l .SetNotice ("unable to load user config" , styles .OutputLevelError )
151
152
break
152
153
}
153
154
154
155
switch {
155
156
case l .showNamespaces && curNs == withoutNamespaceLabel :
156
157
curCfg .CurrentNamespace = ""
157
158
case l .showNamespaces && curNs == allNamespacesLabel :
158
- l .SetNotice ("no namespace selected" , styles .NoticeLevelError )
159
+ l .SetNotice ("no namespace selected" , styles .OutputLevelError )
159
160
case l .showNamespaces && curNs != "" :
160
161
curCfg .CurrentNamespace = curNs
161
162
case ! l .showNamespaces && curWs == allWorkspacesLabel :
162
- l .SetNotice ("no workspace selected" , styles .NoticeLevelError )
163
+ l .SetNotice ("no workspace selected" , styles .OutputLevelError )
163
164
case ! l .showNamespaces && curWs != "" :
164
165
if curWs != curWsCfg .AssignedName () {
165
- l .SetNotice ("current workspace out of sync" , styles .NoticeLevelError )
166
+ l .SetNotice ("current workspace out of sync" , styles .OutputLevelError )
166
167
break
167
168
}
168
169
curCfg .CurrentWorkspace = curWsCfg .AssignedName ()
169
170
}
170
171
171
172
if err := filesystem .WriteConfig (curCfg ); err != nil {
172
173
l .ctx .Logger .Error (err , "unable to write user config" )
173
- l .SetNotice ("unable to write user config" , styles .NoticeLevelError )
174
+ l .SetNotice ("unable to write user config" , styles .OutputLevelError )
174
175
break
175
176
}
176
177
177
178
l .ctx .Config .CurrentWorkspace = curCfg .CurrentWorkspace
178
179
l .ctx .Config .CurrentNamespace = curCfg .CurrentNamespace
179
- l .SetNotice ("context updated" , styles .NoticeLevelInfo )
180
+ l .SetNotice ("context updated" , styles .OutputLevelInfo )
180
181
}
181
182
}
182
183
@@ -219,39 +220,38 @@ func (l *Library) updateExecPanes(msg tea.Msg) (viewport.Model, tea.Cmd) {
219
220
}
220
221
case "e" :
221
222
if curExec == nil {
222
- l .SetNotice ("no executable selected" , styles .NoticeLevelError )
223
+ l .SetNotice ("no executable selected" , styles .OutputLevelError )
223
224
break
224
225
}
225
226
226
227
if err := common .OpenInEditor (curExec .FlowFilePath (), l .ctx .StdIn (), l .ctx .StdOut ()); err != nil {
227
228
l .ctx .Logger .Error (err , "unable to open executable in editor" )
228
- l .SetNotice ("unable to open executable in editor" , styles .NoticeLevelError )
229
+ l .SetNotice ("unable to open executable in editor" , styles .OutputLevelError )
229
230
}
230
231
case "c" :
231
232
if curExec == nil {
232
- l .SetNotice ("no executable selected" , styles .NoticeLevelError )
233
+ l .SetNotice ("no executable selected" , styles .OutputLevelError )
233
234
break
234
235
}
235
236
236
237
if err := clipboard .WriteAll (curExec .Ref ().String ()); err != nil {
237
238
l .ctx .Logger .Error (err , "unable to copy reference to clipboard" )
238
- l .SetNotice ("unable to copy reference to clipboard" , styles .NoticeLevelError )
239
+ l .SetNotice ("unable to copy reference to clipboard" , styles .OutputLevelError )
239
240
} else {
240
- l .SetNotice ("copied reference to clipboard" , styles .NoticeLevelInfo )
241
+ l .SetNotice ("copied reference to clipboard" , styles .OutputLevelInfo )
241
242
}
242
243
case "r" :
243
244
if curExec == nil {
244
- l .SetNotice ("no executable selected" , styles .NoticeLevelError )
245
+ l .SetNotice ("no executable selected" , styles .OutputLevelError )
245
246
break
246
247
}
247
248
248
- go func () {
249
- l .ctx .TUIContainer .Shutdown (func () {
250
- if err := l .cmdRunFunc (curExec .Ref ().String ()); err != nil {
251
- l .ctx .Logger .Fatalx ("unable to execute command" , "error" , err )
252
- }
253
- })
254
- }()
249
+ l .ctx .TUIContainer .Shutdown (func () {
250
+ if err := l .cmdRunFunc (curExec .Ref ().String ()); err != nil {
251
+ l .ctx .Logger .Fatalx ("unable to execute command" , "error" , err )
252
+ }
253
+ })
254
+ os .Exit (0 ) // This is necessary to prevent the app from hanging after the command is run
255
255
case "f" :
256
256
if l .currentPane == 1 {
257
257
break
0 commit comments