Browse Source

rename --no-TTY => --no-tty for consistency

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De Loof 3 months ago
parent
commit
0cdc5c9bff
1 changed files with 8 additions and 1 deletions
  1. 8 1
      cmd/compose/exec.go

+ 8 - 1
cmd/compose/exec.go

@@ -29,6 +29,7 @@ import (
 	"github.com/docker/compose/v2/pkg/compose"
 	"github.com/sirupsen/logrus"
 	"github.com/spf13/cobra"
+	"github.com/spf13/pflag"
 )
 
 type execOpts struct {
@@ -81,7 +82,7 @@ func execCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
 	runCmd.Flags().IntVar(&opts.index, "index", 0, "Index of the container if service has multiple replicas")
 	runCmd.Flags().BoolVarP(&opts.privileged, "privileged", "", false, "Give extended privileges to the process")
 	runCmd.Flags().StringVarP(&opts.user, "user", "u", "", "Run the command as this user")
-	runCmd.Flags().BoolVarP(&opts.noTty, "no-TTY", "T", !dockerCli.Out().IsTerminal(), "Disable pseudo-TTY allocation. By default `docker compose exec` allocates a TTY.")
+	runCmd.Flags().BoolVarP(&opts.noTty, "no-tty", "T", !dockerCli.Out().IsTerminal(), "Disable pseudo-TTY allocation. By default `docker compose exec` allocates a TTY.")
 	runCmd.Flags().StringVarP(&opts.workingDir, "workdir", "w", "", "Path to workdir directory for this command")
 
 	runCmd.Flags().BoolVarP(&opts.interactive, "interactive", "i", true, "Keep STDIN open even if not attached")
@@ -90,6 +91,12 @@ func execCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
 	runCmd.Flags().MarkHidden("tty") //nolint:errcheck
 
 	runCmd.Flags().SetInterspersed(false)
+	runCmd.Flags().SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName {
+		if name == "no-TTY" { // legacy
+			name = "no-tty"
+		}
+		return pflag.NormalizedName(name)
+	})
 	return runCmd
 }