From 86fb843bd886d6b738ae67645227e412ae4ce0cd Mon Sep 17 00:00:00 2001 From: mitchell Date: Wed, 18 Dec 2024 16:32:11 -0500 Subject: [PATCH 1/2] Installers should not default to non-interactive. --- cmd/state-installer/cmd.go | 2 +- cmd/state-remote-installer/main.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/state-installer/cmd.go b/cmd/state-installer/cmd.go index dc9f1deb72..89a5450319 100644 --- a/cmd/state-installer/cmd.go +++ b/cmd/state-installer/cmd.go @@ -105,7 +105,7 @@ func main() { OutWriter: os.Stdout, ErrWriter: os.Stderr, Colored: true, - Interactive: false, + Interactive: term.IsTerminal(int(os.Stdin.Fd())), }) if err != nil { multilog.Critical("Could not set up output handler: " + errs.JoinMessage(err)) diff --git a/cmd/state-remote-installer/main.go b/cmd/state-remote-installer/main.go index 7aa6a5653f..af903268b6 100644 --- a/cmd/state-remote-installer/main.go +++ b/cmd/state-remote-installer/main.go @@ -29,6 +29,7 @@ import ( "github.com/ActiveState/cli/internal/runbits/errors" "github.com/ActiveState/cli/internal/runbits/panics" "github.com/ActiveState/cli/internal/updater" + "golang.org/x/term" ) type Params struct { @@ -90,7 +91,7 @@ func main() { OutWriter: os.Stdout, ErrWriter: os.Stderr, Colored: true, - Interactive: false, + Interactive: term.IsTerminal(int(os.Stdin.Fd())), }) if err != nil { logging.Error("Could not set up output handler: " + errs.JoinMessage(err)) From 9d57da838d311ce3308526e5f13044c2c8c39278 Mon Sep 17 00:00:00 2001 From: mitchell Date: Wed, 18 Dec 2024 17:01:35 -0500 Subject: [PATCH 2/2] Fixed remote installer accepting TOS in non-interactive mode. --- cmd/state-remote-installer/main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/state-remote-installer/main.go b/cmd/state-remote-installer/main.go index af903268b6..8d2c3c6116 100644 --- a/cmd/state-remote-installer/main.go +++ b/cmd/state-remote-installer/main.go @@ -173,9 +173,13 @@ func main() { } func execute(out output.Outputer, prompt prompt.Prompter, cfg *config.Instance, an analytics.Dispatcher, args []string, params *Params) error { + if params.nonInteractive { + prompt.SetInteractive(false) + } + defaultChoice := params.nonInteractive msg := locale.Tr("tos_disclaimer", constants.TermsOfServiceURLLatest) msg += locale.Tr("tos_disclaimer_prompt", constants.TermsOfServiceURLLatest) - cont, err := prompt.Confirm(locale.Tr("install_remote_title"), msg, ptr.To(true), nil) + cont, err := prompt.Confirm(locale.Tr("install_remote_title"), msg, &defaultChoice, nil) if err != nil { return errs.Wrap(err, "Not confirmed") }