Skip to content

Commit

Permalink
Merge pull request #3617 from ActiveState/mitchell/dx-3193-2
Browse files Browse the repository at this point in the history
Installers should not default to non-interactive.
  • Loading branch information
mitchell-as authored Dec 19, 2024
2 parents 370782b + 9d57da8 commit 7eaa7e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/state-installer/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
9 changes: 7 additions & 2 deletions cmd/state-remote-installer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -172,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")
}
Expand Down

0 comments on commit 7eaa7e1

Please sign in to comment.