Skip to content

Commit 8615e9a

Browse files
ndeloofglours
authored andcommitted
deprecate --y, prefer --yes
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent b237289 commit 8615e9a

File tree

9 files changed

+39
-10
lines changed

9 files changed

+39
-10
lines changed

cmd/compose/create.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ import (
2626

2727
"github.com/compose-spec/compose-go/v2/types"
2828
"github.com/docker/cli/cli/command"
29+
"github.com/sirupsen/logrus"
2930
"github.com/spf13/cobra"
31+
"github.com/spf13/pflag"
3032

3133
"github.com/docker/compose/v2/pkg/api"
3234
)
@@ -81,7 +83,15 @@ func createCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service
8183
flags.BoolVar(&opts.noRecreate, "no-recreate", false, "If containers already exist, don't recreate them. Incompatible with --force-recreate.")
8284
flags.BoolVar(&opts.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file")
8385
flags.StringArrayVar(&opts.scale, "scale", []string{}, "Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.")
84-
flags.BoolVarP(&opts.AssumeYes, "y", "y", false, `Assume "yes" as answer to all prompts and run non-interactively`)
86+
flags.BoolVarP(&opts.AssumeYes, "yes", "y", false, `Assume "yes" as answer to all prompts and run non-interactively`)
87+
flags.SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName {
88+
// assumeYes was introduced by mistake as `--y`
89+
if name == "y" {
90+
logrus.Warn("--y is deprecated, please use --yes instead")
91+
name = "yes"
92+
}
93+
return pflag.NormalizedName(name)
94+
})
8595
return cmd
8696
}
8797

cmd/compose/publish.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ import (
2121
"errors"
2222

2323
"github.com/docker/cli/cli/command"
24+
"github.com/sirupsen/logrus"
2425
"github.com/spf13/cobra"
26+
"github.com/spf13/pflag"
2527

2628
"github.com/docker/compose/v2/pkg/api"
2729
)
@@ -50,7 +52,15 @@ func publishCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Servic
5052
flags.BoolVar(&opts.resolveImageDigests, "resolve-image-digests", false, "Pin image tags to digests")
5153
flags.StringVar(&opts.ociVersion, "oci-version", "", "OCI image/artifact specification version (automatically determined by default)")
5254
flags.BoolVar(&opts.withEnvironment, "with-env", false, "Include environment variables in the published OCI artifact")
53-
flags.BoolVarP(&opts.assumeYes, "y", "y", false, `Assume "yes" as answer to all prompts`)
55+
flags.BoolVarP(&opts.assumeYes, "yes", "y", false, `Assume "yes" as answer to all prompts`)
56+
flags.SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName {
57+
// assumeYes was introduced by mistake as `--y`
58+
if name == "y" {
59+
logrus.Warn("--y is deprecated, please use --yes instead")
60+
name = "yes"
61+
}
62+
return pflag.NormalizedName(name)
63+
})
5464

5565
return cmd
5666
}

cmd/compose/up.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ import (
2727
"github.com/compose-spec/compose-go/v2/types"
2828
"github.com/docker/cli/cli/command"
2929
xprogress "github.com/moby/buildkit/util/progress/progressui"
30+
"github.com/sirupsen/logrus"
3031
"github.com/spf13/cobra"
32+
"github.com/spf13/pflag"
3133

3234
"github.com/docker/compose/v2/cmd/formatter"
3335
"github.com/docker/compose/v2/pkg/api"
@@ -145,7 +147,6 @@ func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *c
145147
flags := upCmd.Flags()
146148
flags.BoolVarP(&up.Detach, "detach", "d", false, "Detached mode: Run containers in the background")
147149
flags.BoolVar(&create.Build, "build", false, "Build images before starting containers")
148-
flags.BoolVarP(&create.AssumeYes, "y", "y", false, `Assume "yes" as answer to all prompts and run non-interactively`)
149150
flags.BoolVar(&create.noBuild, "no-build", false, "Don't build an image, even if it's policy")
150151
flags.StringVar(&create.Pull, "pull", "policy", `Pull image before running ("always"|"missing"|"never")`)
151152
flags.BoolVar(&create.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file")
@@ -171,7 +172,15 @@ func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *c
171172
flags.IntVar(&up.waitTimeout, "wait-timeout", 0, "Maximum duration in seconds to wait for the project to be running|healthy")
172173
flags.BoolVarP(&up.watch, "watch", "w", false, "Watch source code and rebuild/refresh containers when files are updated.")
173174
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.")
174-
175+
flags.BoolVarP(&create.AssumeYes, "yes", "y", false, `Assume "yes" as answer to all prompts and run non-interactively`)
176+
flags.SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName {
177+
// assumeYes was introduced by mistake as `--y`
178+
if name == "y" {
179+
logrus.Warn("--y is deprecated, please use --yes instead")
180+
name = "yes"
181+
}
182+
return pflag.NormalizedName(name)
183+
})
175184
return upCmd
176185
}
177186

docs/reference/compose_alpha_publish.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Publish compose application
1111
| `--oci-version` | `string` | | OCI image/artifact specification version (automatically determined by default) |
1212
| `--resolve-image-digests` | `bool` | | Pin image tags to digests |
1313
| `--with-env` | `bool` | | Include environment variables in the published OCI artifact |
14-
| `-y`, `--y` | `bool` | | Assume "yes" as answer to all prompts |
14+
| `-y`, `--yes` | `bool` | | Assume "yes" as answer to all prompts |
1515

1616

1717
<!---MARKER_GEN_END-->

docs/reference/compose_create.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Creates containers for a service
1616
| `--quiet-pull` | `bool` | | Pull without printing progress information |
1717
| `--remove-orphans` | `bool` | | Remove containers for services not defined in the Compose file |
1818
| `--scale` | `stringArray` | | Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present. |
19-
| `-y`, `--y` | `bool` | | Assume "yes" as answer to all prompts and run non-interactively |
19+
| `-y`, `--yes` | `bool` | | Assume "yes" as answer to all prompts and run non-interactively |
2020

2121

2222
<!---MARKER_GEN_END-->

docs/reference/compose_up.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ If the process is interrupted using `SIGINT` (ctrl + C) or `SIGTERM`, the contai
5353
| `--wait` | `bool` | | Wait for services to be running\|healthy. Implies detached mode. |
5454
| `--wait-timeout` | `int` | `0` | Maximum duration in seconds to wait for the project to be running\|healthy |
5555
| `-w`, `--watch` | `bool` | | Watch source code and rebuild/refresh containers when files are updated. |
56-
| `-y`, `--y` | `bool` | | Assume "yes" as answer to all prompts and run non-interactively |
56+
| `-y`, `--yes` | `bool` | | Assume "yes" as answer to all prompts and run non-interactively |
5757

5858

5959
<!---MARKER_GEN_END-->

docs/reference/docker_compose_alpha_publish.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ options:
3535
experimentalcli: false
3636
kubernetes: false
3737
swarm: false
38-
- option: "y"
38+
- option: "yes"
3939
shorthand: "y"
4040
value_type: bool
4141
default_value: "false"

docs/reference/docker_compose_create.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ options:
8888
experimentalcli: false
8989
kubernetes: false
9090
swarm: false
91-
- option: "y"
91+
- option: "yes"
9292
shorthand: "y"
9393
value_type: bool
9494
default_value: "false"

docs/reference/docker_compose_up.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ options:
309309
experimentalcli: false
310310
kubernetes: false
311311
swarm: false
312-
- option: "y"
312+
- option: "yes"
313313
shorthand: "y"
314314
value_type: bool
315315
default_value: "false"

0 commit comments

Comments
 (0)