From ffe309f59582208b2441399c8983cd9f371f3163 Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Fri, 19 Mar 2021 17:24:56 +0100 Subject: [PATCH] Deprecated flag --no-ansi Signed-off-by: Guillaume Tardif --- cli/cmd/compose/compose.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cli/cmd/compose/compose.go b/cli/cmd/compose/compose.go index e18c5c0b1..c504bcf07 100644 --- a/cli/cmd/compose/compose.go +++ b/cli/cmd/compose/compose.go @@ -103,18 +103,26 @@ func (o *projectOptions) toProjectOptions() (*cli.ProjectOptions, error) { func Command(contextType string) *cobra.Command { opts := projectOptions{} var ansi string + var noAnsi bool command := &cobra.Command{ Short: "Docker Compose", Use: "compose", TraverseChildren: true, PersistentPreRunE: func(cmd *cobra.Command, args []string) error { + if noAnsi { + if ansi != "auto" { + return errors.New(aec.Apply(`cannot specify DEPRECATED "--no-ansi" and "--ansi". Please use only "--ansi".`, aec.RedF)) + } + ansi = "never" + fmt.Fprint(os.Stderr, aec.Apply("option '--no-ansi' is DEPRECATED ! Please use '--ansi' instead.\n", aec.RedF)) + } formatter.SetANSIMode(ansi) if opts.WorkDir != "" { if opts.ProjectDir != "" { return errors.New(aec.Apply(`cannot specify DEPRECATED "--workdir" and "--project-directory". Please use only "--project-directory" instead.`, aec.RedF)) } opts.ProjectDir = opts.WorkDir - fmt.Fprint(os.Stderr, aec.Apply(`option "--workdir" is DEPRECATED at root level! Please use "--project-directory" instead.\n`, aec.RedF)) + fmt.Fprint(os.Stderr, aec.Apply("option '--workdir' is DEPRECATED at root level! Please use '--project-directory' instead.\n", aec.RedF)) } if contextType == store.DefaultContextType || contextType == store.LocalContextType { Warning = "The new 'docker compose' command is currently experimental. " + @@ -156,5 +164,7 @@ func Command(contextType string) *cobra.Command { command.Flags().SetInterspersed(false) opts.addProjectFlags(command.Flags()) command.Flags().StringVar(&ansi, "ansi", "auto", `Control when to print ANSI control characters ("never"|"always"|"auto")`) + command.Flags().BoolVar(&noAnsi, "no-ansi", false, `Do not print ANSI control characters (DEPRECATED)`) + command.Flags().MarkHidden("no-ansi") //nolint:errcheck return command }