@@ -21,9 +21,7 @@ import (
2121 "io"
2222 "sync"
2323
24- "github.com/containerd/console"
25- "github.com/moby/term"
26- "github.com/sirupsen/logrus"
24+ "github.com/docker/cli/cli/streams"
2725 "golang.org/x/sync/errgroup"
2826
2927 "github.com/docker/compose/v2/pkg/api"
@@ -59,22 +57,22 @@ type progressFunc func(context.Context) error
5957type progressFuncWithStatus func (context.Context ) (string , error )
6058
6159// Run will run a writer and the progress function in parallel
62- func Run (ctx context.Context , pf progressFunc , out io. Writer ) error {
60+ func Run (ctx context.Context , pf progressFunc , out * streams. Out ) error {
6361 _ , err := RunWithStatus (ctx , func (ctx context.Context ) (string , error ) {
6462 return "" , pf (ctx )
6563 }, out , "Running" )
6664 return err
6765}
6866
69- func RunWithTitle (ctx context.Context , pf progressFunc , out io. Writer , progressTitle string ) error {
67+ func RunWithTitle (ctx context.Context , pf progressFunc , out * streams. Out , progressTitle string ) error {
7068 _ , err := RunWithStatus (ctx , func (ctx context.Context ) (string , error ) {
7169 return "" , pf (ctx )
7270 }, out , progressTitle )
7371 return err
7472}
7573
7674// RunWithStatus will run a writer and the progress function in parallel and return a status
77- func RunWithStatus (ctx context.Context , pf progressFuncWithStatus , out io. Writer , progressTitle string ) (string , error ) {
75+ func RunWithStatus (ctx context.Context , pf progressFuncWithStatus , out * streams. Out , progressTitle string ) (string , error ) {
7876 eg , _ := errgroup .WithContext (ctx )
7977 w , err := NewWriter (ctx , out , progressTitle )
8078 var result string
@@ -115,25 +113,22 @@ const (
115113var Mode = ModeAuto
116114
117115// NewWriter returns a new multi-progress writer
118- func NewWriter (ctx context.Context , out io. Writer , progressTitle string ) (Writer , error ) {
119- _ , isTerminal := term . GetFdInfo ( out )
116+ func NewWriter (ctx context.Context , out * streams. Out , progressTitle string ) (Writer , error ) {
117+ isTerminal := out . IsTerminal ( )
120118 dryRun , ok := ctx .Value (api.DryRunKey {}).(bool )
121119 if ! ok {
122120 dryRun = false
123121 }
124122 if Mode == ModeQuiet {
125123 return quiet {}, nil
126124 }
127- f , isConsole := out .(console.File ) // see https://github.com/docker/compose/issues/10560
128- if Mode == ModeAuto && isTerminal && isConsole {
129- return newTTYWriter (f , dryRun , progressTitle )
125+
126+ tty := Mode == ModeTTY
127+ if Mode == ModeAuto && isTerminal {
128+ tty = true
130129 }
131- if Mode == ModeTTY {
132- if ! isConsole {
133- logrus .Warn ("Terminal is not a POSIX console" )
134- } else {
135- return newTTYWriter (f , dryRun , progressTitle )
136- }
130+ if tty {
131+ return newTTYWriter (out , dryRun , progressTitle )
137132 }
138133 return & plainWriter {
139134 out : out ,
@@ -142,14 +137,9 @@ func NewWriter(ctx context.Context, out io.Writer, progressTitle string) (Writer
142137 }, nil
143138}
144139
145- func newTTYWriter (out console.File , dryRun bool , progressTitle string ) (Writer , error ) {
146- con , err := console .ConsoleFromFile (out )
147- if err != nil {
148- return nil , err
149- }
150-
140+ func newTTYWriter (out io.Writer , dryRun bool , progressTitle string ) (Writer , error ) {
151141 return & ttyWriter {
152- out : con ,
142+ out : out ,
153143 eventIDs : []string {},
154144 events : map [string ]Event {},
155145 repeated : false ,
0 commit comments