From 9b3d07382affbbf165af047f083a9c99f26f73c3 Mon Sep 17 00:00:00 2001 From: sophia Date: Mon, 10 May 2021 15:48:10 -0500 Subject: [PATCH] Enable multi ui to check for interactive uis --- internal/core/project.go | 2 +- internal/runner/ui_multi.go | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/internal/core/project.go b/internal/core/project.go index 98cb303de..421a666ce 100644 --- a/internal/core/project.go +++ b/internal/core/project.go @@ -273,7 +273,7 @@ func (p *Project) callDynamicFunc( argmapper.Typed( p.jobInfo, p.dir, - terminal.ConsoleUI(ctx), + p.UI, ), ) diff --git a/internal/runner/ui_multi.go b/internal/runner/ui_multi.go index fc191c0ed..d3dc7015e 100644 --- a/internal/runner/ui_multi.go +++ b/internal/runner/ui_multi.go @@ -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 }