mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 00:47:48 +08:00
24 lines
403 B
Go
24 lines
403 B
Go
package commands
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
|
|
"github.com/docker/cli/cli/command"
|
|
)
|
|
|
|
func prompt(ctx context.Context, ins io.Reader, out io.Writer, msg string) (bool, error) {
|
|
done := make(chan struct{})
|
|
var ok bool
|
|
go func() {
|
|
ok = command.PromptForConfirmation(ins, out, msg)
|
|
close(done)
|
|
}()
|
|
select {
|
|
case <-ctx.Done():
|
|
return false, context.Cause(ctx)
|
|
case <-done:
|
|
return ok, nil
|
|
}
|
|
}
|