diff --git a/cli/azd/pkg/input/console.go b/cli/azd/pkg/input/console.go index d87770b8ab7..05888bf1155 100644 --- a/cli/azd/pkg/input/console.go +++ b/cli/azd/pkg/input/console.go @@ -141,8 +141,15 @@ type AskerConsole struct { // the writer the console was constructed with, and what we reset to when SetWriter(nil) is called. defaultWriter io.Writer // the writer which output is written to. - writer io.Writer - formatter output.Formatter + writer io.Writer + formatter output.Formatter + + // isTerminal controls whether terminal-style input/output will be used. + // + // When isTerminal is false, the following notable behaviors apply: + // - Spinner progress will be written as standard newline messages. + // - Prompting assumes a non-terminal environment, where output written and input received are machine-friendly text, + // stripped of formatting characters. isTerminal bool noPrompt bool // when non nil, use this client instead of prompting ourselves on the console. @@ -1056,24 +1063,15 @@ func NewConsole( // IsTerminal returns true if the given file descriptors are attached to a terminal, // taking into account of environment variables that force TTY behavior. func IsTerminal(stdoutFd uintptr, stdinFd uintptr) bool { - // User override to force non-TTY behavior - if ok, _ := strconv.ParseBool(os.Getenv("AZD_DEBUG_FORCE_NO_TTY")); ok { - return false + // User override to force TTY behavior + if forceTty, err := strconv.ParseBool(os.Getenv("AZD_FORCE_TTY")); err == nil { + return forceTty } // By default, detect if we are running on CI and force no TTY mode if we are. - // Allow for an override if this is not desired. - shouldDetectCI := true - if strVal, has := os.LookupEnv("AZD_TERM_SKIP_CI_DETECT"); has { - skip, err := strconv.ParseBool(strVal) - if err != nil { - log.Println("AZD_TERM_SKIP_CI_DETECT is not a valid boolean value") - } else if skip { - shouldDetectCI = false - } - } - - if shouldDetectCI && resource.IsRunningOnCI() { + // If this is affecting you locally while debugging on a CI machine, + // use the override AZD_FORCE_TTY=true. + if resource.IsRunningOnCI() { return false }