Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit ffe309f

Browse files
committed
Deprecated flag --no-ansi
Signed-off-by: Guillaume Tardif <[email protected]>
1 parent 6562ec8 commit ffe309f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

cli/cmd/compose/compose.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,26 @@ func (o *projectOptions) toProjectOptions() (*cli.ProjectOptions, error) {
103103
func Command(contextType string) *cobra.Command {
104104
opts := projectOptions{}
105105
var ansi string
106+
var noAnsi bool
106107
command := &cobra.Command{
107108
Short: "Docker Compose",
108109
Use: "compose",
109110
TraverseChildren: true,
110111
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
112+
if noAnsi {
113+
if ansi != "auto" {
114+
return errors.New(aec.Apply(`cannot specify DEPRECATED "--no-ansi" and "--ansi". Please use only "--ansi".`, aec.RedF))
115+
}
116+
ansi = "never"
117+
fmt.Fprint(os.Stderr, aec.Apply("option '--no-ansi' is DEPRECATED ! Please use '--ansi' instead.\n", aec.RedF))
118+
}
111119
formatter.SetANSIMode(ansi)
112120
if opts.WorkDir != "" {
113121
if opts.ProjectDir != "" {
114122
return errors.New(aec.Apply(`cannot specify DEPRECATED "--workdir" and "--project-directory". Please use only "--project-directory" instead.`, aec.RedF))
115123
}
116124
opts.ProjectDir = opts.WorkDir
117-
fmt.Fprint(os.Stderr, aec.Apply(`option "--workdir" is DEPRECATED at root level! Please use "--project-directory" instead.\n`, aec.RedF))
125+
fmt.Fprint(os.Stderr, aec.Apply("option '--workdir' is DEPRECATED at root level! Please use '--project-directory' instead.\n", aec.RedF))
118126
}
119127
if contextType == store.DefaultContextType || contextType == store.LocalContextType {
120128
Warning = "The new 'docker compose' command is currently experimental. " +
@@ -156,5 +164,7 @@ func Command(contextType string) *cobra.Command {
156164
command.Flags().SetInterspersed(false)
157165
opts.addProjectFlags(command.Flags())
158166
command.Flags().StringVar(&ansi, "ansi", "auto", `Control when to print ANSI control characters ("never"|"always"|"auto")`)
167+
command.Flags().BoolVar(&noAnsi, "no-ansi", false, `Do not print ANSI control characters (DEPRECATED)`)
168+
command.Flags().MarkHidden("no-ansi") //nolint:errcheck
159169
return command
160170
}

0 commit comments

Comments
 (0)