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

Commit 40a24af

Browse files
authored
Merge pull request #1445 from gtardif/ansi_flag
2 parents d3dbc90 + 584ceab commit 40a24af

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

cli/cmd/compose/compose.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,26 @@ func (o *projectOptions) toProjectOptions(po ...cli.ProjectOptionsFn) (*cli.Proj
104104
func Command(contextType string) *cobra.Command {
105105
opts := projectOptions{}
106106
var ansi string
107+
var noAnsi bool
107108
command := &cobra.Command{
108109
Short: "Docker Compose",
109110
Use: "compose",
110111
TraverseChildren: true,
111112
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
113+
if noAnsi {
114+
if ansi != "auto" {
115+
return errors.New(`cannot specify DEPRECATED "--no-ansi" and "--ansi". Please use only "--ansi"`)
116+
}
117+
ansi = "never"
118+
fmt.Fprint(os.Stderr, aec.Apply("option '--no-ansi' is DEPRECATED ! Please use '--ansi' instead.\n", aec.RedF))
119+
}
112120
formatter.SetANSIMode(ansi)
113121
if opts.WorkDir != "" {
114122
if opts.ProjectDir != "" {
115-
return errors.New(aec.Apply(`cannot specify DEPRECATED "--workdir" and "--project-directory". Please use only "--project-directory" instead.`, aec.RedF))
123+
return errors.New(`cannot specify DEPRECATED "--workdir" and "--project-directory". Please use only "--project-directory" instead`)
116124
}
117125
opts.ProjectDir = opts.WorkDir
118-
fmt.Fprint(os.Stderr, aec.Apply(`option "--workdir" is DEPRECATED at root level! Please use "--project-directory" instead.\n`, aec.RedF))
126+
fmt.Fprint(os.Stderr, aec.Apply("option '--workdir' is DEPRECATED at root level! Please use '--project-directory' instead.\n", aec.RedF))
119127
}
120128
if contextType == store.DefaultContextType || contextType == store.LocalContextType {
121129
Warning = "The new 'docker compose' command is currently experimental. " +
@@ -157,5 +165,7 @@ func Command(contextType string) *cobra.Command {
157165
command.Flags().SetInterspersed(false)
158166
opts.addProjectFlags(command.Flags())
159167
command.Flags().StringVar(&ansi, "ansi", "auto", `Control when to print ANSI control characters ("never"|"always"|"auto")`)
168+
command.Flags().BoolVar(&noAnsi, "no-ansi", false, `Do not print ANSI control characters (DEPRECATED)`)
169+
command.Flags().MarkHidden("no-ansi") //nolint:errcheck
160170
return command
161171
}

cli/cmd/compose/pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func pullCommand(p *projectOptions) *cobra.Command {
4747
Short: "Pull service images",
4848
RunE: func(cmd *cobra.Command, args []string) error {
4949
if opts.noParallel {
50-
fmt.Fprint(os.Stderr, aec.Apply(`option "--no-parallel" is DEPRECATED and will be ignored.\n`, aec.RedF))
50+
fmt.Fprint(os.Stderr, aec.Apply("option '--no-parallel' is DEPRECATED and will be ignored.\n", aec.RedF))
5151
}
5252
return runPull(cmd.Context(), opts, args)
5353
},

0 commit comments

Comments
 (0)