Skip to content

Commit 7eaa7e1

Browse files
authored
Merge pull request #3617 from ActiveState/mitchell/dx-3193-2
Installers should not default to non-interactive.
2 parents 370782b + 9d57da8 commit 7eaa7e1

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

cmd/state-installer/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func main() {
105105
OutWriter: os.Stdout,
106106
ErrWriter: os.Stderr,
107107
Colored: true,
108-
Interactive: false,
108+
Interactive: term.IsTerminal(int(os.Stdin.Fd())),
109109
})
110110
if err != nil {
111111
multilog.Critical("Could not set up output handler: " + errs.JoinMessage(err))

cmd/state-remote-installer/main.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/ActiveState/cli/internal/runbits/errors"
3030
"github.com/ActiveState/cli/internal/runbits/panics"
3131
"github.com/ActiveState/cli/internal/updater"
32+
"golang.org/x/term"
3233
)
3334

3435
type Params struct {
@@ -90,7 +91,7 @@ func main() {
9091
OutWriter: os.Stdout,
9192
ErrWriter: os.Stderr,
9293
Colored: true,
93-
Interactive: false,
94+
Interactive: term.IsTerminal(int(os.Stdin.Fd())),
9495
})
9596
if err != nil {
9697
logging.Error("Could not set up output handler: " + errs.JoinMessage(err))
@@ -172,9 +173,13 @@ func main() {
172173
}
173174

174175
func execute(out output.Outputer, prompt prompt.Prompter, cfg *config.Instance, an analytics.Dispatcher, args []string, params *Params) error {
176+
if params.nonInteractive {
177+
prompt.SetInteractive(false)
178+
}
179+
defaultChoice := params.nonInteractive
175180
msg := locale.Tr("tos_disclaimer", constants.TermsOfServiceURLLatest)
176181
msg += locale.Tr("tos_disclaimer_prompt", constants.TermsOfServiceURLLatest)
177-
cont, err := prompt.Confirm(locale.Tr("install_remote_title"), msg, ptr.To(true), nil)
182+
cont, err := prompt.Confirm(locale.Tr("install_remote_title"), msg, &defaultChoice, nil)
178183
if err != nil {
179184
return errs.Wrap(err, "Not confirmed")
180185
}

0 commit comments

Comments
 (0)