Enable multi ui to check for interactive uis
This commit is contained in:
parent
aff6edc31b
commit
9b3d07382a
@ -273,7 +273,7 @@ func (p *Project) callDynamicFunc(
|
||||
argmapper.Typed(
|
||||
p.jobInfo,
|
||||
p.dir,
|
||||
terminal.ConsoleUI(ctx),
|
||||
p.UI,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package runner
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"github.com/hashicorp/vagrant-plugin-sdk/terminal"
|
||||
@ -22,10 +23,26 @@ func (u *multiUI) Close() error {
|
||||
}
|
||||
|
||||
func (u *multiUI) Input(input *terminal.Input) (string, error) {
|
||||
return "", terminal.ErrNonInteractive
|
||||
numInteractive := 0
|
||||
var term terminal.UI
|
||||
for _, u := range u.UIs {
|
||||
if u.Interactive() {
|
||||
numInteractive += 1
|
||||
term = u
|
||||
}
|
||||
}
|
||||
if numInteractive > 1 {
|
||||
return "", errors.New("More than one interactive terminal available. Please ensure only one interactive terminal is available")
|
||||
}
|
||||
return term.Input(input)
|
||||
}
|
||||
|
||||
func (u *multiUI) Interactive() bool {
|
||||
for _, u := range u.UIs {
|
||||
if u.Interactive() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user