Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow a TTY to be allocated with -t #10180

Merged
merged 1 commit into from
Jan 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion cmd/compose/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type runOptions struct {
Detach bool
Remove bool
noTty bool
tty bool
interactive bool
user string
workdir string
Expand Down Expand Up @@ -133,6 +134,13 @@ func runCommand(p *ProjectOptions, streams api.Streams, backend api.Service) *co
}
opts.entrypointCmd = command
}
if cmd.Flags().Changed("tty") {
if cmd.Flags().Changed("no-TTY") {
return fmt.Errorf("--tty and --no-TTY can't be used together")
} else {
opts.noTty = !opts.tty
}
}
return nil
}),
RunE: Adapt(func(ctx context.Context, args []string) error {
Expand Down Expand Up @@ -165,7 +173,7 @@ func runCommand(p *ProjectOptions, streams api.Streams, backend api.Service) *co
flags.BoolVar(&createOpts.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file.")

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

flags.SetNormalizeFunc(normalizeRunFlags)
Expand Down