diff --git a/cmd/compose/compose.go b/cmd/compose/compose.go index 2be3ab15738..cbc03508dbf 100644 --- a/cmd/compose/compose.go +++ b/cmd/compose/compose.go @@ -66,8 +66,6 @@ const ( ComposeIgnoreOrphans = "COMPOSE_IGNORE_ORPHANS" // ComposeEnvFiles defines the env files to use if --env-file isn't used ComposeEnvFiles = "COMPOSE_ENV_FILES" - // ComposeMenu defines if the navigation menu should be rendered. Can be also set via --menu - ComposeMenu = "COMPOSE_MENU" // ComposeProgress defines type of progress output, if --progress isn't used ComposeProgress = "COMPOSE_PROGRESS" ) diff --git a/cmd/compose/up.go b/cmd/compose/up.go index dcde8b4ae04..cd3f02881ae 100644 --- a/cmd/compose/up.go +++ b/cmd/compose/up.go @@ -33,7 +33,6 @@ import ( "github.com/docker/compose/v2/cmd/formatter" "github.com/docker/compose/v2/pkg/api" - ui "github.com/docker/compose/v2/pkg/progress" "github.com/docker/compose/v2/pkg/utils" ) @@ -44,23 +43,21 @@ type composeOptions struct { type upOptions struct { *composeOptions - Detach bool - noStart bool - noDeps bool - cascadeStop bool - cascadeFail bool - exitCodeFrom string - noColor bool - noPrefix bool - attachDependencies bool - attach []string - noAttach []string - timestamp bool - wait bool - waitTimeout int - watch bool - navigationMenu bool - navigationMenuChanged bool + Detach bool + noStart bool + noDeps bool + cascadeStop bool + cascadeFail bool + exitCodeFrom string + noColor bool + noPrefix bool + attachDependencies bool + attach []string + noAttach []string + timestamp bool + wait bool + waitTimeout int + watch bool } func (opts upOptions) apply(project *types.Project, services []string) (*types.Project, error) { @@ -82,22 +79,6 @@ func (opts upOptions) apply(project *types.Project, services []string) (*types.P return project, nil } -func (opts *upOptions) validateNavigationMenu(dockerCli command.Cli) { - if !dockerCli.Out().IsTerminal() { - opts.navigationMenu = false - return - } - // If --menu flag was not set - if !opts.navigationMenuChanged { - if envVar, ok := os.LookupEnv(ComposeMenu); ok { - opts.navigationMenu = utils.StringToBool(envVar) - return - } - // ...and COMPOSE_MENU env var is not defined we want the default value to be true - opts.navigationMenu = true - } -} - func (opts upOptions) OnExit() api.Cascade { switch { case opts.cascadeStop: @@ -119,7 +100,6 @@ func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *c PreRunE: AdaptCmd(func(ctx context.Context, cmd *cobra.Command, args []string) error { create.pullChanged = cmd.Flags().Changed("pull") create.timeChanged = cmd.Flags().Changed("timeout") - up.navigationMenuChanged = cmd.Flags().Changed("menu") if !cmd.Flags().Changed("remove-orphans") { create.removeOrphans = utils.StringToBool(os.Getenv(ComposeRemoveOrphans)) } @@ -134,8 +114,6 @@ func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *c return errors.New("cannot combine --attach and --attach-dependencies") } - up.validateNavigationMenu(dockerCli) - if !p.All && len(project.Services) == 0 { return fmt.Errorf("no service selected") } @@ -171,7 +149,6 @@ func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *c flags.BoolVar(&up.wait, "wait", false, "Wait for services to be running|healthy. Implies detached mode.") flags.IntVar(&up.waitTimeout, "wait-timeout", 0, "Maximum duration in seconds to wait for the project to be running|healthy") flags.BoolVarP(&up.watch, "watch", "w", false, "Watch source code and rebuild/refresh containers when files are updated.") - flags.BoolVar(&up.navigationMenu, "menu", false, "Enable interactive shortcuts when running attached. Incompatible with --detach. Can also be enable/disable by setting COMPOSE_MENU environment var.") flags.BoolVarP(&create.AssumeYes, "yes", "y", false, `Assume "yes" as answer to all prompts and run non-interactively`) flags.SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName { // assumeYes was introduced by mistake as `--y` @@ -181,6 +158,10 @@ func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *c } return pflag.NormalizedName(name) }) + + flags.Bool("menu", false, "DISABLED") + _ = flags.MarkHidden("menu") + return upCmd } @@ -223,7 +204,6 @@ func validateFlags(up *upOptions, create *createOptions) error { return nil } -//nolint:gocyclo func runUp( ctx context.Context, dockerCli command.Cli, @@ -322,16 +302,15 @@ func runUp( return backend.Up(ctx, project, api.UpOptions{ Create: create, Start: api.StartOptions{ - Project: project, - Attach: consumer, - AttachTo: attach, - ExitCodeFrom: upOptions.exitCodeFrom, - OnExit: upOptions.OnExit(), - Wait: upOptions.wait, - WaitTimeout: timeout, - Watch: upOptions.watch, - Services: services, - NavigationMenu: upOptions.navigationMenu && ui.Mode != "plain" && dockerCli.In().IsTerminal(), + Project: project, + Attach: consumer, + AttachTo: attach, + ExitCodeFrom: upOptions.exitCodeFrom, + OnExit: upOptions.OnExit(), + Wait: upOptions.wait, + WaitTimeout: timeout, + Watch: upOptions.watch, + Services: services, }, }) } diff --git a/cmd/formatter/ansi.go b/cmd/formatter/ansi.go index 0d59cf5016e..a1da0c0ecf4 100644 --- a/cmd/formatter/ansi.go +++ b/cmd/formatter/ansi.go @@ -18,8 +18,6 @@ package formatter import ( "fmt" - - "github.com/acarl005/stripansi" ) var disableAnsi bool @@ -78,14 +76,6 @@ func clearLine() { fmt.Print(ansi("[2K")) } -func moveCursorUp(lines int) { - if disableAnsi { - return - } - // Does not add new lines - fmt.Print(ansi(fmt.Sprintf("[%dA", lines))) -} - func moveCursorDown(lines int) { if disableAnsi { return @@ -93,15 +83,3 @@ func moveCursorDown(lines int) { // Does not add new lines fmt.Print(ansi(fmt.Sprintf("[%dB", lines))) } - -func newLine() { - // Like \n - fmt.Print("\012") -} - -func lenAnsi(s string) int { - // len has into consideration ansi codes, if we want - // the len of the actual len(string) we need to strip - // all ansi codes - return len(stripansi.Strip(s)) -} diff --git a/cmd/formatter/shortcut.go b/cmd/formatter/shortcut.go deleted file mode 100644 index d1c7363196f..00000000000 --- a/cmd/formatter/shortcut.go +++ /dev/null @@ -1,359 +0,0 @@ -/* - Copyright 2024 Docker Compose CLI authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package formatter - -import ( - "context" - "errors" - "fmt" - "math" - "os" - "syscall" - "time" - - "github.com/buger/goterm" - "github.com/compose-spec/compose-go/v2/types" - "github.com/docker/compose/v2/internal/tracing" - "github.com/docker/compose/v2/pkg/api" - "github.com/eiannone/keyboard" - "github.com/skratchdot/open-golang/open" -) - -const DISPLAY_ERROR_TIME = 10 - -type KeyboardError struct { - err error - timeStart time.Time -} - -func (ke *KeyboardError) shouldDisplay() bool { - return ke.err != nil && int(time.Since(ke.timeStart).Seconds()) < DISPLAY_ERROR_TIME -} - -func (ke *KeyboardError) printError(height int, info string) { - if ke.shouldDisplay() { - errMessage := ke.err.Error() - - moveCursor(height-1-extraLines(info)-extraLines(errMessage), 0) - clearLine() - - fmt.Print(errMessage) - } -} - -func (ke *KeyboardError) addError(prefix string, err error) { - ke.timeStart = time.Now() - - prefix = ansiColor(CYAN, fmt.Sprintf("%s →", prefix), BOLD) - errorString := fmt.Sprintf("%s %s", prefix, err.Error()) - - ke.err = errors.New(errorString) -} - -func (ke *KeyboardError) error() string { - return ke.err.Error() -} - -type KeyboardWatch struct { - Watching bool - Watcher Feature -} - -// Feature is an compose feature that can be started/stopped by a menu command -type Feature interface { - Start(context.Context) error - Stop() error -} - -type KEYBOARD_LOG_LEVEL int - -const ( - NONE KEYBOARD_LOG_LEVEL = 0 - INFO KEYBOARD_LOG_LEVEL = 1 - DEBUG KEYBOARD_LOG_LEVEL = 2 -) - -type LogKeyboard struct { - kError KeyboardError - Watch *KeyboardWatch - IsDockerDesktopActive bool - logLevel KEYBOARD_LOG_LEVEL - signalChannel chan<- os.Signal -} - -func NewKeyboardManager(isDockerDesktopActive bool, sc chan<- os.Signal) *LogKeyboard { - return &LogKeyboard{ - IsDockerDesktopActive: isDockerDesktopActive, - logLevel: INFO, - signalChannel: sc, - } -} - -func (lk *LogKeyboard) Decorate(l api.LogConsumer) api.LogConsumer { - return logDecorator{ - decorated: l, - Before: lk.clearNavigationMenu, - After: lk.PrintKeyboardInfo, - } -} - -func (lk *LogKeyboard) PrintKeyboardInfo() { - if lk.logLevel == INFO { - lk.printNavigationMenu() - } -} - -// Creates space to print error and menu string -func (lk *LogKeyboard) createBuffer(lines int) { - if lk.kError.shouldDisplay() { - extraLines := extraLines(lk.kError.error()) + 1 - lines += extraLines - } - - // get the string - infoMessage := lk.navigationMenu() - // calculate how many lines we need to display the menu info - // might be needed a line break - extraLines := extraLines(infoMessage) + 1 - lines += extraLines - - if lines > 0 { - allocateSpace(lines) - moveCursorUp(lines) - } -} - -func (lk *LogKeyboard) printNavigationMenu() { - offset := 1 - lk.clearNavigationMenu() - lk.createBuffer(offset) - - if lk.logLevel == INFO { - height := goterm.Height() - menu := lk.navigationMenu() - - carriageReturn() - saveCursor() - - lk.kError.printError(height, menu) - - moveCursor(height-extraLines(menu), 0) - clearLine() - fmt.Print(menu) - - carriageReturn() - restoreCursor() - } -} - -func (lk *LogKeyboard) navigationMenu() string { - var openDDInfo string - if lk.IsDockerDesktopActive { - openDDInfo = shortcutKeyColor("v") + navColor(" View in Docker Desktop") - } - - var openDDUI string - if openDDInfo != "" { - openDDUI = navColor(" ") - } - if lk.IsDockerDesktopActive { - openDDUI = openDDUI + shortcutKeyColor("o") + navColor(" View Config") - } - - var watchInfo string - if openDDInfo != "" || openDDUI != "" { - watchInfo = navColor(" ") - } - isEnabled := " Enable" - if lk.Watch != nil && lk.Watch.Watching { - isEnabled = " Disable" - } - watchInfo = watchInfo + shortcutKeyColor("w") + navColor(isEnabled+" Watch") - return openDDInfo + openDDUI + watchInfo -} - -func (lk *LogKeyboard) clearNavigationMenu() { - height := goterm.Height() - carriageReturn() - saveCursor() - - // clearLine() - for i := 0; i < height; i++ { - moveCursorDown(1) - clearLine() - } - restoreCursor() -} - -func (lk *LogKeyboard) openDockerDesktop(ctx context.Context, project *types.Project) { - if !lk.IsDockerDesktopActive { - return - } - go func() { - _ = tracing.EventWrapFuncForErrGroup(ctx, "menu/gui", tracing.SpanOptions{}, - func(ctx context.Context) error { - link := fmt.Sprintf("docker-desktop://dashboard/apps/%s", project.Name) - err := open.Run(link) - if err != nil { - err = fmt.Errorf("could not open Docker Desktop") - lk.keyboardError("View", err) - } - return err - })() - }() -} - -func (lk *LogKeyboard) openDDComposeUI(ctx context.Context, project *types.Project) { - if !lk.IsDockerDesktopActive { - return - } - go func() { - _ = tracing.EventWrapFuncForErrGroup(ctx, "menu/gui/composeview", tracing.SpanOptions{}, - func(ctx context.Context) error { - link := fmt.Sprintf("docker-desktop://dashboard/docker-compose/%s", project.Name) - err := open.Run(link) - if err != nil { - err = fmt.Errorf("could not open Docker Desktop Compose UI") - lk.keyboardError("View Config", err) - } - return err - })() - }() -} - -func (lk *LogKeyboard) openDDWatchDocs(ctx context.Context, project *types.Project) { - go func() { - _ = tracing.EventWrapFuncForErrGroup(ctx, "menu/gui/watch", tracing.SpanOptions{}, - func(ctx context.Context) error { - link := fmt.Sprintf("docker-desktop://dashboard/docker-compose/%s/watch", project.Name) - err := open.Run(link) - if err != nil { - err = fmt.Errorf("could not open Docker Desktop Compose UI") - lk.keyboardError("Watch Docs", err) - } - return err - })() - }() -} - -func (lk *LogKeyboard) keyboardError(prefix string, err error) { - lk.kError.addError(prefix, err) - - lk.printNavigationMenu() - timer1 := time.NewTimer((DISPLAY_ERROR_TIME + 1) * time.Second) - go func() { - <-timer1.C - lk.printNavigationMenu() - }() -} - -func (lk *LogKeyboard) ToggleWatch(ctx context.Context, options api.UpOptions) { - if lk.Watch == nil { - return - } - if lk.Watch.Watching { - err := lk.Watch.Watcher.Stop() - if err != nil { - options.Start.Attach.Err(api.WatchLogger, err.Error()) - } else { - lk.Watch.Watching = false - } - } else { - go func() { - _ = tracing.EventWrapFuncForErrGroup(ctx, "menu/watch", tracing.SpanOptions{}, - func(ctx context.Context) error { - err := lk.Watch.Watcher.Start(ctx) - if err != nil { - options.Start.Attach.Err(api.WatchLogger, err.Error()) - } else { - lk.Watch.Watching = true - } - return err - })() - }() - } -} - -func (lk *LogKeyboard) HandleKeyEvents(ctx context.Context, event keyboard.KeyEvent, project *types.Project, options api.UpOptions) { - switch kRune := event.Rune; kRune { - case 'v': - lk.openDockerDesktop(ctx, project) - case 'w': - if lk.Watch == nil { - // we try to open watch docs if DD is installed - if lk.IsDockerDesktopActive { - lk.openDDWatchDocs(ctx, project) - } - // either way we mark menu/watch as an error - go func() { - _ = tracing.EventWrapFuncForErrGroup(ctx, "menu/watch", tracing.SpanOptions{}, - func(ctx context.Context) error { - err := fmt.Errorf("watch is not yet configured. Learn more: %s", ansiColor(CYAN, "https://docs.docker.com/compose/file-watch/")) - lk.keyboardError("Watch", err) - return err - })() - }() - } - lk.ToggleWatch(ctx, options) - case 'o': - lk.openDDComposeUI(ctx, project) - } - switch key := event.Key; key { - case keyboard.KeyCtrlC: - _ = keyboard.Close() - lk.clearNavigationMenu() - showCursor() - - lk.logLevel = NONE - // will notify main thread to kill and will handle gracefully - lk.signalChannel <- syscall.SIGINT - case keyboard.KeyEnter: - newLine() - lk.printNavigationMenu() - } -} - -func (lk *LogKeyboard) EnableWatch(enabled bool, watcher Feature) { - lk.Watch = &KeyboardWatch{ - Watching: enabled, - Watcher: watcher, - } -} - -func allocateSpace(lines int) { - for i := 0; i < lines; i++ { - clearLine() - newLine() - carriageReturn() - } -} - -func extraLines(s string) int { - return int(math.Floor(float64(lenAnsi(s)) / float64(goterm.Width()))) -} - -func shortcutKeyColor(key string) string { - foreground := "38;2" - black := "0;0;0" - background := "48;2" - white := "255;255;255" - return ansiColor(foreground+";"+black+";"+background+";"+white, key, BOLD) -} - -func navColor(key string) string { - return ansiColor(FAINT, key) -} diff --git a/docs/reference/compose_up.md b/docs/reference/compose_up.md index b831cb16d34..6a6bdc25280 100644 --- a/docs/reference/compose_up.md +++ b/docs/reference/compose_up.md @@ -23,37 +23,36 @@ If the process is interrupted using `SIGINT` (ctrl + C) or `SIGTERM`, the contai ### Options -| Name | Type | Default | Description | -|:-------------------------------|:--------------|:---------|:----------------------------------------------------------------------------------------------------------------------------------------------------| -| `--abort-on-container-exit` | `bool` | | Stops all containers if any container was stopped. Incompatible with -d | -| `--abort-on-container-failure` | `bool` | | Stops all containers if any container exited with failure. Incompatible with -d | -| `--always-recreate-deps` | `bool` | | Recreate dependent containers. Incompatible with --no-recreate. | -| `--attach` | `stringArray` | | Restrict attaching to the specified services. Incompatible with --attach-dependencies. | -| `--attach-dependencies` | `bool` | | Automatically attach to log output of dependent services | -| `--build` | `bool` | | Build images before starting containers | -| `-d`, `--detach` | `bool` | | Detached mode: Run containers in the background | -| `--dry-run` | `bool` | | Execute command in dry run mode | -| `--exit-code-from` | `string` | | Return the exit code of the selected service container. Implies --abort-on-container-exit | -| `--force-recreate` | `bool` | | Recreate containers even if their configuration and image haven't changed | -| `--menu` | `bool` | | Enable interactive shortcuts when running attached. Incompatible with --detach. Can also be enable/disable by setting COMPOSE_MENU environment var. | -| `--no-attach` | `stringArray` | | Do not attach (stream logs) to the specified services | -| `--no-build` | `bool` | | Don't build an image, even if it's policy | -| `--no-color` | `bool` | | Produce monochrome output | -| `--no-deps` | `bool` | | Don't start linked services | -| `--no-log-prefix` | `bool` | | Don't print prefix in logs | -| `--no-recreate` | `bool` | | If containers already exist, don't recreate them. Incompatible with --force-recreate. | -| `--no-start` | `bool` | | Don't start the services after creating them | -| `--pull` | `string` | `policy` | Pull image before running ("always"\|"missing"\|"never") | -| `--quiet-pull` | `bool` | | Pull without printing progress information | -| `--remove-orphans` | `bool` | | Remove containers for services not defined in the Compose file | -| `-V`, `--renew-anon-volumes` | `bool` | | Recreate anonymous volumes instead of retrieving data from the previous containers | -| `--scale` | `stringArray` | | Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present. | -| `-t`, `--timeout` | `int` | `0` | Use this timeout in seconds for container shutdown when attached or when containers are already running | -| `--timestamps` | `bool` | | Show timestamps | -| `--wait` | `bool` | | Wait for services to be running\|healthy. Implies detached mode. | -| `--wait-timeout` | `int` | `0` | Maximum duration in seconds to wait for the project to be running\|healthy | -| `-w`, `--watch` | `bool` | | Watch source code and rebuild/refresh containers when files are updated. | -| `-y`, `--yes` | `bool` | | Assume "yes" as answer to all prompts and run non-interactively | +| Name | Type | Default | Description | +|:-------------------------------|:--------------|:---------|:--------------------------------------------------------------------------------------------------------| +| `--abort-on-container-exit` | `bool` | | Stops all containers if any container was stopped. Incompatible with -d | +| `--abort-on-container-failure` | `bool` | | Stops all containers if any container exited with failure. Incompatible with -d | +| `--always-recreate-deps` | `bool` | | Recreate dependent containers. Incompatible with --no-recreate. | +| `--attach` | `stringArray` | | Restrict attaching to the specified services. Incompatible with --attach-dependencies. | +| `--attach-dependencies` | `bool` | | Automatically attach to log output of dependent services | +| `--build` | `bool` | | Build images before starting containers | +| `-d`, `--detach` | `bool` | | Detached mode: Run containers in the background | +| `--dry-run` | `bool` | | Execute command in dry run mode | +| `--exit-code-from` | `string` | | Return the exit code of the selected service container. Implies --abort-on-container-exit | +| `--force-recreate` | `bool` | | Recreate containers even if their configuration and image haven't changed | +| `--no-attach` | `stringArray` | | Do not attach (stream logs) to the specified services | +| `--no-build` | `bool` | | Don't build an image, even if it's policy | +| `--no-color` | `bool` | | Produce monochrome output | +| `--no-deps` | `bool` | | Don't start linked services | +| `--no-log-prefix` | `bool` | | Don't print prefix in logs | +| `--no-recreate` | `bool` | | If containers already exist, don't recreate them. Incompatible with --force-recreate. | +| `--no-start` | `bool` | | Don't start the services after creating them | +| `--pull` | `string` | `policy` | Pull image before running ("always"\|"missing"\|"never") | +| `--quiet-pull` | `bool` | | Pull without printing progress information | +| `--remove-orphans` | `bool` | | Remove containers for services not defined in the Compose file | +| `-V`, `--renew-anon-volumes` | `bool` | | Recreate anonymous volumes instead of retrieving data from the previous containers | +| `--scale` | `stringArray` | | Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present. | +| `-t`, `--timeout` | `int` | `0` | Use this timeout in seconds for container shutdown when attached or when containers are already running | +| `--timestamps` | `bool` | | Show timestamps | +| `--wait` | `bool` | | Wait for services to be running\|healthy. Implies detached mode. | +| `--wait-timeout` | `int` | `0` | Maximum duration in seconds to wait for the project to be running\|healthy | +| `-w`, `--watch` | `bool` | | Watch source code and rebuild/refresh containers when files are updated. | +| `-y`, `--yes` | `bool` | | Assume "yes" as answer to all prompts and run non-interactively | diff --git a/docs/reference/docker_compose_up.yaml b/docs/reference/docker_compose_up.yaml index 47e0c5259eb..6e69977ab19 100644 --- a/docs/reference/docker_compose_up.yaml +++ b/docs/reference/docker_compose_up.yaml @@ -122,10 +122,9 @@ options: - option: menu value_type: bool default_value: "false" - description: | - Enable interactive shortcuts when running attached. Incompatible with --detach. Can also be enable/disable by setting COMPOSE_MENU environment var. + description: DISABLED deprecated: false - hidden: false + hidden: true experimental: false experimentalcli: false kubernetes: false diff --git a/go.mod b/go.mod index 9c1d26b7940..8941d4e651b 100644 --- a/go.mod +++ b/go.mod @@ -39,7 +39,6 @@ require ( github.com/opencontainers/image-spec v1.1.1 github.com/otiai10/copy v1.14.1 github.com/sirupsen/logrus v1.9.3 - github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 github.com/spf13/cobra v1.9.1 github.com/spf13/pflag v1.0.6 github.com/stretchr/testify v1.10.0 diff --git a/go.sum b/go.sum index 14e909e04d7..4b7342ba9b6 100644 --- a/go.sum +++ b/go.sum @@ -438,8 +438,6 @@ github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 h1:JIAuq3EEf9cgbU6AtGPK4CTG3Zf6CKMNqf0MHTggAUA= -github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966/go.mod h1:sUM3LWHvSMaG192sy56D9F7CNvL7jUJVXoqM1QKLnog= github.com/spdx/tools-golang v0.5.5 h1:61c0KLfAcNqAjlg6UNMdkwpMernhw3zVRwDZ2x9XOmk= github.com/spdx/tools-golang v0.5.5/go.mod h1:MVIsXx8ZZzaRWNQpUDhC4Dud34edUYJYecciXgrw5vE= github.com/spf13/cast v0.0.0-20150508191742-4d07383ffe94 h1:JmfC365KywYwHB946TTiQWEb8kqPY+pybPLoGE9GgVk= diff --git a/pkg/api/api.go b/pkg/api/api.go index b57a142a617..09b134d1995 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -244,9 +244,8 @@ type StartOptions struct { Wait bool WaitTimeout time.Duration // Services passed in the command line to be started - Services []string - Watch bool - NavigationMenu bool + Services []string + Watch bool } type Cascade int diff --git a/pkg/compose/up.go b/pkg/compose/up.go index 04cf06e9972..9e64c689f53 100644 --- a/pkg/compose/up.go +++ b/pkg/compose/up.go @@ -35,7 +35,6 @@ import ( "github.com/docker/docker/errdefs" "github.com/eiannone/keyboard" "github.com/hashicorp/go-multierror" - "github.com/sirupsen/logrus" ) func (s *composeService) Up(ctx context.Context, project *types.Project, options api.UpOptions) error { //nolint:gocyclo @@ -73,39 +72,15 @@ func (s *composeService) Up(ctx context.Context, project *types.Project, options defer signal.Stop(signalChan) var isTerminated atomic.Bool - var ( - logConsumer = options.Start.Attach - navigationMenu *formatter.LogKeyboard - kEvents <-chan keyboard.KeyEvent - ) - if options.Start.NavigationMenu { - kEvents, err = keyboard.GetKeys(100) - if err != nil { - logrus.Warnf("could not start menu, an error occurred while starting: %v", err) - options.Start.NavigationMenu = false - } else { - defer keyboard.Close() //nolint:errcheck - isDockerDesktopActive := s.isDesktopIntegrationActive() - tracing.KeyboardMetrics(ctx, options.Start.NavigationMenu, isDockerDesktopActive) - navigationMenu = formatter.NewKeyboardManager(isDockerDesktopActive, signalChan) - logConsumer = navigationMenu.Decorate(logConsumer) - } - } - - tui := formatter.NewStopping(logConsumer) + tui := formatter.NewStopping(options.Start.Attach) defer tui.Close() - logConsumer = tui - watcher, err := NewWatcher(project, options, s.watch, logConsumer) + watcher, err := NewWatcher(project, options, s.watch, tui) if err != nil && options.Start.Watch { return err } - if navigationMenu != nil && watcher != nil { - navigationMenu.EnableWatch(options.Start.Watch, watcher) - } - - printer := newLogPrinter(logConsumer) + printer := newLogPrinter(tui) doneCh := make(chan bool) eg.Go(func() error { @@ -118,7 +93,7 @@ func (s *composeService) Up(ctx context.Context, project *types.Project, options Services: options.Create.Services, Project: project, }, printer.HandleEvent) - }, s.stdinfo(), logConsumer) + }, s.stdinfo(), tui) }) isTerminated.Store(true) first = false @@ -155,8 +130,6 @@ func (s *composeService) Up(ctx context.Context, project *types.Project, options return err }) return nil - case event := <-kEvents: - navigationMenu.HandleKeyEvents(ctx, event, project, options) } } }) @@ -194,7 +167,7 @@ func (s *composeService) Up(ctx context.Context, project *types.Project, options Services: options.Create.Services, Project: project, }, printer.HandleEvent) - }, s.stdinfo(), logConsumer) + }, s.stdinfo(), tui) }) } })