Skip to content

Commit

Permalink
deprecate --y, prefer --yes
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof authored and glours committed Mar 11, 2025
1 parent b237289 commit 8615e9a
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 10 deletions.
12 changes: 11 additions & 1 deletion cmd/compose/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
}

Expand Down
12 changes: 11 additions & 1 deletion cmd/compose/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
}
Expand Down
13 changes: 11 additions & 2 deletions cmd/compose/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/compose_alpha_publish.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |


<!---MARKER_GEN_END-->
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/compose_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |


<!---MARKER_GEN_END-->
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/compose_up.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |


<!---MARKER_GEN_END-->
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/docker_compose_alpha_publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ options:
experimentalcli: false
kubernetes: false
swarm: false
- option: "y"
- option: "yes"
shorthand: "y"
value_type: bool
default_value: "false"
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/docker_compose_create.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ options:
experimentalcli: false
kubernetes: false
swarm: false
- option: "y"
- option: "yes"
shorthand: "y"
value_type: bool
default_value: "false"
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/docker_compose_up.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ options:
experimentalcli: false
kubernetes: false
swarm: false
- option: "y"
- option: "yes"
shorthand: "y"
value_type: bool
default_value: "false"
Expand Down

0 comments on commit 8615e9a

Please sign in to comment.