diff --git a/cmd/compose/create.go b/cmd/compose/create.go index 54e6060e8..a96d63fe1 100644 --- a/cmd/compose/create.go +++ b/cmd/compose/create.go @@ -26,7 +26,9 @@ import ( "github.com/compose-spec/compose-go/v2/types" "github.com/docker/cli/cli/command" + "github.com/sirupsen/logrus" "github.com/spf13/cobra" + "github.com/spf13/pflag" "github.com/docker/compose/v2/pkg/api" ) @@ -81,7 +83,15 @@ func createCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service flags.BoolVar(&opts.noRecreate, "no-recreate", false, "If containers already exist, don't recreate them. Incompatible with --force-recreate.") flags.BoolVar(&opts.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file") flags.StringArrayVar(&opts.scale, "scale", []string{}, "Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.") - flags.BoolVarP(&opts.AssumeYes, "y", "y", false, `Assume "yes" as answer to all prompts and run non-interactively`) + flags.BoolVarP(&opts.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` + if name == "y" { + logrus.Warn("--y is deprecated, please use --yes instead") + name = "yes" + } + return pflag.NormalizedName(name) + }) return cmd } diff --git a/cmd/compose/publish.go b/cmd/compose/publish.go index 961420eba..c6882328c 100644 --- a/cmd/compose/publish.go +++ b/cmd/compose/publish.go @@ -21,7 +21,9 @@ import ( "errors" "github.com/docker/cli/cli/command" + "github.com/sirupsen/logrus" "github.com/spf13/cobra" + "github.com/spf13/pflag" "github.com/docker/compose/v2/pkg/api" ) @@ -50,7 +52,15 @@ func publishCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Servic flags.BoolVar(&opts.resolveImageDigests, "resolve-image-digests", false, "Pin image tags to digests") flags.StringVar(&opts.ociVersion, "oci-version", "", "OCI image/artifact specification version (automatically determined by default)") flags.BoolVar(&opts.withEnvironment, "with-env", false, "Include environment variables in the published OCI artifact") - flags.BoolVarP(&opts.assumeYes, "y", "y", false, `Assume "yes" as answer to all prompts`) + flags.BoolVarP(&opts.assumeYes, "yes", "y", false, `Assume "yes" as answer to all prompts`) + flags.SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName { + // assumeYes was introduced by mistake as `--y` + if name == "y" { + logrus.Warn("--y is deprecated, please use --yes instead") + name = "yes" + } + return pflag.NormalizedName(name) + }) return cmd } diff --git a/cmd/compose/up.go b/cmd/compose/up.go index 6eee08a70..ba428ef96 100644 --- a/cmd/compose/up.go +++ b/cmd/compose/up.go @@ -27,7 +27,9 @@ import ( "github.com/compose-spec/compose-go/v2/types" "github.com/docker/cli/cli/command" xprogress "github.com/moby/buildkit/util/progress/progressui" + "github.com/sirupsen/logrus" "github.com/spf13/cobra" + "github.com/spf13/pflag" "github.com/docker/compose/v2/cmd/formatter" "github.com/docker/compose/v2/pkg/api" @@ -145,7 +147,6 @@ func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *c flags := upCmd.Flags() flags.BoolVarP(&up.Detach, "detach", "d", false, "Detached mode: Run containers in the background") flags.BoolVar(&create.Build, "build", false, "Build images before starting containers") - flags.BoolVarP(&create.AssumeYes, "y", "y", false, `Assume "yes" as answer to all prompts and run non-interactively`) flags.BoolVar(&create.noBuild, "no-build", false, "Don't build an image, even if it's policy") flags.StringVar(&create.Pull, "pull", "policy", `Pull image before running ("always"|"missing"|"never")`) 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 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` + if name == "y" { + logrus.Warn("--y is deprecated, please use --yes instead") + name = "yes" + } + return pflag.NormalizedName(name) + }) return upCmd } diff --git a/docs/reference/compose_alpha_publish.md b/docs/reference/compose_alpha_publish.md index 7d3655352..6e77d7145 100644 --- a/docs/reference/compose_alpha_publish.md +++ b/docs/reference/compose_alpha_publish.md @@ -11,7 +11,7 @@ Publish compose application | `--oci-version` | `string` | | OCI image/artifact specification version (automatically determined by default) | | `--resolve-image-digests` | `bool` | | Pin image tags to digests | | `--with-env` | `bool` | | Include environment variables in the published OCI artifact | -| `-y`, `--y` | `bool` | | Assume "yes" as answer to all prompts | +| `-y`, `--yes` | `bool` | | Assume "yes" as answer to all prompts | diff --git a/docs/reference/compose_create.md b/docs/reference/compose_create.md index b87cce857..4b0b876da 100644 --- a/docs/reference/compose_create.md +++ b/docs/reference/compose_create.md @@ -16,7 +16,7 @@ Creates containers for a service | `--quiet-pull` | `bool` | | Pull without printing progress information | | `--remove-orphans` | `bool` | | Remove containers for services not defined in the Compose file | | `--scale` | `stringArray` | | Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present. | -| `-y`, `--y` | `bool` | | Assume "yes" as answer to all prompts and run non-interactively | +| `-y`, `--yes` | `bool` | | Assume "yes" as answer to all prompts and run non-interactively | diff --git a/docs/reference/compose_up.md b/docs/reference/compose_up.md index d1478cdd3..b831cb16d 100644 --- a/docs/reference/compose_up.md +++ b/docs/reference/compose_up.md @@ -53,7 +53,7 @@ If the process is interrupted using `SIGINT` (ctrl + C) or `SIGTERM`, the contai | `--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`, `--y` | `bool` | | Assume "yes" as answer to all prompts and run non-interactively | +| `-y`, `--yes` | `bool` | | Assume "yes" as answer to all prompts and run non-interactively | diff --git a/docs/reference/docker_compose_alpha_publish.yaml b/docs/reference/docker_compose_alpha_publish.yaml index 91600ac8b..156667747 100644 --- a/docs/reference/docker_compose_alpha_publish.yaml +++ b/docs/reference/docker_compose_alpha_publish.yaml @@ -35,7 +35,7 @@ options: experimentalcli: false kubernetes: false swarm: false - - option: "y" + - option: "yes" shorthand: "y" value_type: bool default_value: "false" diff --git a/docs/reference/docker_compose_create.yaml b/docs/reference/docker_compose_create.yaml index 7cb764098..f6ab1b868 100644 --- a/docs/reference/docker_compose_create.yaml +++ b/docs/reference/docker_compose_create.yaml @@ -88,7 +88,7 @@ options: experimentalcli: false kubernetes: false swarm: false - - option: "y" + - option: "yes" shorthand: "y" value_type: bool default_value: "false" diff --git a/docs/reference/docker_compose_up.yaml b/docs/reference/docker_compose_up.yaml index 0ed31b359..47e0c5259 100644 --- a/docs/reference/docker_compose_up.yaml +++ b/docs/reference/docker_compose_up.yaml @@ -309,7 +309,7 @@ options: experimentalcli: false kubernetes: false swarm: false - - option: "y" + - option: "yes" shorthand: "y" value_type: bool default_value: "false"