| 360 | } |
| 361 | |
| 362 | func newIOStreams(cfg gh.Config, invokingAgent agents.AgentName) *iostreams.IOStreams { |
| 363 | io := iostreams.System() |
| 364 | |
| 365 | if _, ghPromptDisabled := os.LookupEnv("GH_PROMPT_DISABLED"); ghPromptDisabled { |
| 366 | io.SetNeverPrompt(true) |
| 367 | } else if prompt := cfg.Prompt(""); prompt.Value == "disabled" { |
| 368 | io.SetNeverPrompt(true) |
| 369 | } |
| 370 | |
| 371 | falseyValues := []string{"false", "0", "no", ""} |
| 372 | |
| 373 | accessiblePrompterValue, accessiblePrompterIsSet := os.LookupEnv("GH_ACCESSIBLE_PROMPTER") |
| 374 | if accessiblePrompterIsSet { |
| 375 | if !slices.Contains(falseyValues, accessiblePrompterValue) { |
| 376 | io.SetAccessiblePrompterEnabled(true) |
| 377 | } |
| 378 | } else if prompt := cfg.AccessiblePrompter(""); prompt.Value == "enabled" { |
| 379 | io.SetAccessiblePrompterEnabled(true) |
| 380 | } |
| 381 | |
| 382 | experimentalPrompterValue, experimentalPrompterIsSet := os.LookupEnv("GH_EXPERIMENTAL_PROMPTER") |
| 383 | if experimentalPrompterIsSet { |
| 384 | if !slices.Contains(falseyValues, experimentalPrompterValue) { |
| 385 | io.SetExperimentalPrompterEnabled(true) |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | ghSpinnerDisabledValue, ghSpinnerDisabledIsSet := os.LookupEnv("GH_SPINNER_DISABLED") |
| 390 | if ghSpinnerDisabledIsSet { |
| 391 | if !slices.Contains(falseyValues, ghSpinnerDisabledValue) { |
| 392 | io.SetSpinnerDisabled(true) |
| 393 | } |
| 394 | } else if invokingAgent != "" { |
| 395 | io.SetSpinnerDisabled(true) |
| 396 | } else if spinner := cfg.Spinner(""); spinner.Value == "disabled" { |
| 397 | io.SetSpinnerDisabled(true) |
| 398 | } |
| 399 | |
| 400 | // Pager precedence |
| 401 | // 1. GH_PAGER |
| 402 | // 2. pager from config |
| 403 | // 3. PAGER |
| 404 | if ghPager, ghPagerExists := os.LookupEnv("GH_PAGER"); ghPagerExists { |
| 405 | io.SetPager(ghPager) |
| 406 | } else if pager := cfg.Pager(""); pager.Value != "" { |
| 407 | io.SetPager(pager.Value) |
| 408 | } |
| 409 | |
| 410 | if ghColorLabels, ghColorLabelsExists := os.LookupEnv("GH_COLOR_LABELS"); ghColorLabelsExists { |
| 411 | switch ghColorLabels { |
| 412 | case "", "0", "false", "no": |
| 413 | io.SetColorLabels(false) |
| 414 | default: |
| 415 | io.SetColorLabels(true) |
| 416 | } |
| 417 | } else if prompt := cfg.ColorLabels(""); prompt.Value == "enabled" { |
| 418 | io.SetColorLabels(true) |
| 419 | } |