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