From 416498441c00320302fc01a2a5d9f4f159886c5c Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Thu, 17 Feb 2022 11:48:09 +0100 Subject: [PATCH] declare `--volume` as an alias for `--volumes` Signed-off-by: Nicolas De Loof --- cmd/compose/down.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmd/compose/down.go b/cmd/compose/down.go index 4be6ef0dc..ba0279f38 100644 --- a/cmd/compose/down.go +++ b/cmd/compose/down.go @@ -22,7 +22,9 @@ import ( "time" "github.com/compose-spec/compose-go/types" + "github.com/sirupsen/logrus" "github.com/spf13/cobra" + "github.com/spf13/pflag" "github.com/docker/compose/v2/pkg/api" ) @@ -62,6 +64,14 @@ func downCommand(p *projectOptions, backend api.Service) *cobra.Command { flags.IntVarP(&opts.timeout, "timeout", "t", 10, "Specify a shutdown timeout in seconds") flags.BoolVarP(&opts.volumes, "volumes", "v", false, " Remove named volumes declared in the `volumes` section of the Compose file and anonymous volumes attached to containers.") flags.StringVar(&opts.images, "rmi", "", `Remove images used by services. "local" remove only images that don't have a custom tag ("local"|"all")`) + flags.SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName { + switch name { + case "volume": + name = "volumes" + logrus.Warn("--volume is deprecated, please use --volumes") + } + return pflag.NormalizedName(name) + }) return downCmd }