@@ -31,6 +31,7 @@ import (
31
31
"github.com/docker/compose/v2/pkg/progress"
32
32
"github.com/eiannone/keyboard"
33
33
"github.com/hashicorp/go-multierror"
34
+ "github.com/sirupsen/logrus"
34
35
)
35
36
36
37
func (s * composeService ) Up (ctx context.Context , project * types.Project , options api.UpOptions ) error { //nolint:gocyclo
@@ -89,22 +90,7 @@ func (s *composeService) Up(ctx context.Context, project *types.Project, options
89
90
first = false
90
91
}
91
92
92
- var kEvents <- chan keyboard.KeyEvent
93
- isWatchConfigured := s .shouldWatch (project )
94
- isDockerDesktopActive := s .isDesktopIntegrationActive ()
95
-
96
- tracing .KeyboardMetrics (ctx , options .Start .NavigationMenu , isDockerDesktopActive , isWatchConfigured )
97
- if options .Start .NavigationMenu {
98
- kEvents , err = keyboard .GetKeys (100 )
99
- if err != nil {
100
- panic (err )
101
- }
102
- formatter .NewKeyboardManager (ctx , isDockerDesktopActive , isWatchConfigured , signalChan , s .Watch )
103
- if options .Start .Watch {
104
- formatter .KeyboardManager .StartWatch (ctx , project , options )
105
- }
106
- defer formatter .KeyboardManager .KeyboardClose ()
107
- }
93
+ kEvents := s .startMenu (ctx , project , options , signalChan )
108
94
for {
109
95
select {
110
96
case <- doneCh :
@@ -179,3 +165,30 @@ func (s *composeService) Up(ctx context.Context, project *types.Project, options
179
165
}
180
166
return err
181
167
}
168
+
169
+ func (s * composeService ) startMenu (
170
+ ctx context.Context ,
171
+ project * types.Project ,
172
+ options api.UpOptions ,
173
+ sc chan <- os.Signal ,
174
+ ) <- chan keyboard.KeyEvent {
175
+ if ! options .Start .NavigationMenu {
176
+ return nil
177
+ }
178
+ kEvents , err := keyboard .GetKeys (100 )
179
+ keyboardInitiated := err == nil
180
+ if ! keyboardInitiated {
181
+ logrus .Warn ("Could not start Menu - an error occurred while starting." )
182
+ return nil
183
+ }
184
+
185
+ isWatchConfigured := s .shouldWatch (project )
186
+ isDockerDesktopActive := s .isDesktopIntegrationActive ()
187
+ tracing .KeyboardMetrics (ctx , options .Start .NavigationMenu , isDockerDesktopActive , isWatchConfigured )
188
+
189
+ formatter .NewKeyboardManager (ctx , isDockerDesktopActive , isWatchConfigured , sc , s .Watch )
190
+ if options .Start .Watch {
191
+ formatter .KeyboardManager .StartWatch (ctx , project , options )
192
+ }
193
+ return kEvents
194
+ }
0 commit comments