From 5d9fa4bc532c28b8895ac364169c694cec3665f7 Mon Sep 17 00:00:00 2001 From: Joana Hrotko Date: Thu, 28 Mar 2024 17:24:18 +0000 Subject: [PATCH] remove startMenu fn Signed-off-by: Joana Hrotko --- cmd/compose/up.go | 8 ++++---- pkg/compose/up.go | 44 ++++++++++++++++---------------------------- 2 files changed, 20 insertions(+), 32 deletions(-) diff --git a/cmd/compose/up.go b/cmd/compose/up.go index 18bcaa7e93b..7c9cc6e012f 100644 --- a/cmd/compose/up.go +++ b/cmd/compose/up.go @@ -80,13 +80,13 @@ func (opts upOptions) apply(project *types.Project, services []string) (*types.P } func (opts *upOptions) validateNavigationMenu(dockerCli command.Cli, experimentals *experimental.State) { + if !dockerCli.Out().IsTerminal() { + opts.navigationMenu = false + return + } if !opts.navigationMenuChanged { opts.navigationMenu = SetUnchangedOption(ComposeMenu, experimentals.NavBar()) } - - if opts.navigationMenu && !dockerCli.Out().IsTerminal() { - opts.navigationMenu = false - } } func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service, experiments *experimental.State) *cobra.Command { diff --git a/pkg/compose/up.go b/pkg/compose/up.go index 5aea6fb45b8..956dbd766ff 100644 --- a/pkg/compose/up.go +++ b/pkg/compose/up.go @@ -90,7 +90,22 @@ func (s *composeService) Up(ctx context.Context, project *types.Project, options first = false } - kEvents := s.startMenu(ctx, project, options, signalChan) + var kEvents <-chan keyboard.KeyEvent + if options.Start.NavigationMenu { + kEvents, err = keyboard.GetKeys(100) + if err != nil { + logrus.Warn("could not start menu, an error occurred while starting.") + } else { + isWatchConfigured := s.shouldWatch(project) + isDockerDesktopActive := s.isDesktopIntegrationActive() + tracing.KeyboardMetrics(ctx, options.Start.NavigationMenu, isDockerDesktopActive, isWatchConfigured) + + formatter.NewKeyboardManager(ctx, isDockerDesktopActive, isWatchConfigured, signalChan, s.Watch) + if options.Start.Watch { + formatter.KeyboardManager.StartWatch(ctx, project, options) + } + } + } for { select { case <-doneCh: @@ -165,30 +180,3 @@ func (s *composeService) Up(ctx context.Context, project *types.Project, options } return err } - -func (s *composeService) startMenu( - ctx context.Context, - project *types.Project, - options api.UpOptions, - sc chan<- os.Signal, -) <-chan keyboard.KeyEvent { - if !options.Start.NavigationMenu { - return nil - } - kEvents, err := keyboard.GetKeys(100) - keyboardInitiated := err == nil - if !keyboardInitiated { - logrus.Warn("Could not start Menu - an error occurred while starting.") - return nil - } - - isWatchConfigured := s.shouldWatch(project) - isDockerDesktopActive := s.isDesktopIntegrationActive() - tracing.KeyboardMetrics(ctx, options.Start.NavigationMenu, isDockerDesktopActive, isWatchConfigured) - - formatter.NewKeyboardManager(ctx, isDockerDesktopActive, isWatchConfigured, sc, s.Watch) - if options.Start.Watch { - formatter.KeyboardManager.StartWatch(ctx, project, options) - } - return kEvents -}