Skip to content

Commit e94eb05

Browse files
committed
allow a TTY to be allocated with -t
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent c15bf19 commit e94eb05

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cmd/compose/run.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type runOptions struct {
4242
Detach bool
4343
Remove bool
4444
noTty bool
45+
tty bool
4546
interactive bool
4647
user string
4748
workdir string
@@ -133,6 +134,13 @@ func runCommand(p *ProjectOptions, streams api.Streams, backend api.Service) *co
133134
}
134135
opts.entrypointCmd = command
135136
}
137+
if cmd.Flags().Changed("tty") {
138+
if cmd.Flags().Changed("no-TTY") {
139+
return fmt.Errorf("--tty and --no-TTY can't be used together")
140+
} else {
141+
opts.noTty = !opts.tty
142+
}
143+
}
136144
return nil
137145
}),
138146
RunE: Adapt(func(ctx context.Context, args []string) error {
@@ -165,7 +173,7 @@ func runCommand(p *ProjectOptions, streams api.Streams, backend api.Service) *co
165173
flags.BoolVar(&createOpts.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file.")
166174

167175
cmd.Flags().BoolVarP(&opts.interactive, "interactive", "i", true, "Keep STDIN open even if not attached.")
168-
cmd.Flags().BoolP("tty", "t", true, "Allocate a pseudo-TTY.")
176+
cmd.Flags().BoolVarP(&opts.tty, "tty", "t", true, "Allocate a pseudo-TTY.")
169177
cmd.Flags().MarkHidden("tty") //nolint:errcheck
170178

171179
flags.SetNormalizeFunc(normalizeRunFlags)

0 commit comments

Comments
 (0)