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