Skip to content

Commit b91ddce

Browse files
committed
drop navigation menu
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 17ba6c7 commit b91ddce

File tree

10 files changed

+67
-504
lines changed

10 files changed

+67
-504
lines changed

cmd/compose/compose.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ const (
6666
ComposeIgnoreOrphans = "COMPOSE_IGNORE_ORPHANS"
6767
// ComposeEnvFiles defines the env files to use if --env-file isn't used
6868
ComposeEnvFiles = "COMPOSE_ENV_FILES"
69-
// ComposeMenu defines if the navigation menu should be rendered. Can be also set via --menu
70-
ComposeMenu = "COMPOSE_MENU"
7169
// ComposeProgress defines type of progress output, if --progress isn't used
7270
ComposeProgress = "COMPOSE_PROGRESS"
7371
)

cmd/compose/up.go

Lines changed: 28 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import (
3333

3434
"github.com/docker/compose/v2/cmd/formatter"
3535
"github.com/docker/compose/v2/pkg/api"
36-
ui "github.com/docker/compose/v2/pkg/progress"
3736
"github.com/docker/compose/v2/pkg/utils"
3837
)
3938

@@ -44,23 +43,21 @@ type composeOptions struct {
4443

4544
type upOptions struct {
4645
*composeOptions
47-
Detach bool
48-
noStart bool
49-
noDeps bool
50-
cascadeStop bool
51-
cascadeFail bool
52-
exitCodeFrom string
53-
noColor bool
54-
noPrefix bool
55-
attachDependencies bool
56-
attach []string
57-
noAttach []string
58-
timestamp bool
59-
wait bool
60-
waitTimeout int
61-
watch bool
62-
navigationMenu bool
63-
navigationMenuChanged bool
46+
Detach bool
47+
noStart bool
48+
noDeps bool
49+
cascadeStop bool
50+
cascadeFail bool
51+
exitCodeFrom string
52+
noColor bool
53+
noPrefix bool
54+
attachDependencies bool
55+
attach []string
56+
noAttach []string
57+
timestamp bool
58+
wait bool
59+
waitTimeout int
60+
watch bool
6461
}
6562

6663
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
8279
return project, nil
8380
}
8481

85-
func (opts *upOptions) validateNavigationMenu(dockerCli command.Cli) {
86-
if !dockerCli.Out().IsTerminal() {
87-
opts.navigationMenu = false
88-
return
89-
}
90-
// If --menu flag was not set
91-
if !opts.navigationMenuChanged {
92-
if envVar, ok := os.LookupEnv(ComposeMenu); ok {
93-
opts.navigationMenu = utils.StringToBool(envVar)
94-
return
95-
}
96-
// ...and COMPOSE_MENU env var is not defined we want the default value to be true
97-
opts.navigationMenu = true
98-
}
99-
}
100-
10182
func (opts upOptions) OnExit() api.Cascade {
10283
switch {
10384
case opts.cascadeStop:
@@ -119,7 +100,6 @@ func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *c
119100
PreRunE: AdaptCmd(func(ctx context.Context, cmd *cobra.Command, args []string) error {
120101
create.pullChanged = cmd.Flags().Changed("pull")
121102
create.timeChanged = cmd.Flags().Changed("timeout")
122-
up.navigationMenuChanged = cmd.Flags().Changed("menu")
123103
if !cmd.Flags().Changed("remove-orphans") {
124104
create.removeOrphans = utils.StringToBool(os.Getenv(ComposeRemoveOrphans))
125105
}
@@ -134,8 +114,6 @@ func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *c
134114
return errors.New("cannot combine --attach and --attach-dependencies")
135115
}
136116

137-
up.validateNavigationMenu(dockerCli)
138-
139117
if !p.All && len(project.Services) == 0 {
140118
return fmt.Errorf("no service selected")
141119
}
@@ -171,7 +149,6 @@ func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *c
171149
flags.BoolVar(&up.wait, "wait", false, "Wait for services to be running|healthy. Implies detached mode.")
172150
flags.IntVar(&up.waitTimeout, "wait-timeout", 0, "Maximum duration in seconds to wait for the project to be running|healthy")
173151
flags.BoolVarP(&up.watch, "watch", "w", false, "Watch source code and rebuild/refresh containers when files are updated.")
174-
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.")
175152
flags.BoolVarP(&create.AssumeYes, "yes", "y", false, `Assume "yes" as answer to all prompts and run non-interactively`)
176153
flags.SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName {
177154
// assumeYes was introduced by mistake as `--y`
@@ -181,6 +158,10 @@ func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *c
181158
}
182159
return pflag.NormalizedName(name)
183160
})
161+
162+
flags.Bool("menu", false, "DISABLED")
163+
_ = flags.MarkHidden("menu")
164+
184165
return upCmd
185166
}
186167

@@ -223,7 +204,6 @@ func validateFlags(up *upOptions, create *createOptions) error {
223204
return nil
224205
}
225206

226-
//nolint:gocyclo
227207
func runUp(
228208
ctx context.Context,
229209
dockerCli command.Cli,
@@ -322,16 +302,15 @@ func runUp(
322302
return backend.Up(ctx, project, api.UpOptions{
323303
Create: create,
324304
Start: api.StartOptions{
325-
Project: project,
326-
Attach: consumer,
327-
AttachTo: attach,
328-
ExitCodeFrom: upOptions.exitCodeFrom,
329-
OnExit: upOptions.OnExit(),
330-
Wait: upOptions.wait,
331-
WaitTimeout: timeout,
332-
Watch: upOptions.watch,
333-
Services: services,
334-
NavigationMenu: upOptions.navigationMenu && ui.Mode != "plain" && dockerCli.In().IsTerminal(),
305+
Project: project,
306+
Attach: consumer,
307+
AttachTo: attach,
308+
ExitCodeFrom: upOptions.exitCodeFrom,
309+
OnExit: upOptions.OnExit(),
310+
Wait: upOptions.wait,
311+
WaitTimeout: timeout,
312+
Watch: upOptions.watch,
313+
Services: services,
335314
},
336315
})
337316
}

cmd/formatter/ansi.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ package formatter
1818

1919
import (
2020
"fmt"
21-
22-
"github.com/acarl005/stripansi"
2321
)
2422

2523
var disableAnsi bool
@@ -78,30 +76,10 @@ func clearLine() {
7876
fmt.Print(ansi("[2K"))
7977
}
8078

81-
func moveCursorUp(lines int) {
82-
if disableAnsi {
83-
return
84-
}
85-
// Does not add new lines
86-
fmt.Print(ansi(fmt.Sprintf("[%dA", lines)))
87-
}
88-
8979
func moveCursorDown(lines int) {
9080
if disableAnsi {
9181
return
9282
}
9383
// Does not add new lines
9484
fmt.Print(ansi(fmt.Sprintf("[%dB", lines)))
9585
}
96-
97-
func newLine() {
98-
// Like \n
99-
fmt.Print("\012")
100-
}
101-
102-
func lenAnsi(s string) int {
103-
// len has into consideration ansi codes, if we want
104-
// the len of the actual len(string) we need to strip
105-
// all ansi codes
106-
return len(stripansi.Strip(s))
107-
}

0 commit comments

Comments
 (0)