MCPcopy
hub / github.com/cli/cli / System

Function System

pkg/iostreams/iostreams.go:478–523  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

476}
477
478func System() *IOStreams {
479 terminal := ghTerm.FromEnv()
480
481 var stdout fileWriter = os.Stdout
482 // On Windows with no virtual terminal processing support, translate ANSI escape
483 // sequences to console syscalls.
484 if colorableStdout := colorable.NewColorable(os.Stdout); colorableStdout != os.Stdout {
485 // Ensure that the file descriptor of the original stdout is preserved.
486 stdout = &fdWriter{
487 fd: os.Stdout.Fd(),
488 Writer: colorableStdout,
489 }
490 }
491
492 var stderr fileWriter = os.Stderr
493 // On Windows with no virtual terminal processing support, translate ANSI escape
494 // sequences to console syscalls.
495 if colorableStderr := colorable.NewColorable(os.Stderr); colorableStderr != os.Stderr {
496 // Ensure that the file descriptor of the original stderr is preserved.
497 stderr = &fdWriter{
498 fd: os.Stderr.Fd(),
499 Writer: colorableStderr,
500 }
501 }
502
503 io := &IOStreams{
504 In: os.Stdin,
505 Out: stdout,
506 ErrOut: stderr,
507 pagerCommand: os.Getenv("PAGER"),
508 term: &terminal,
509 }
510
511 stdoutIsTTY := io.IsStdoutTTY()
512 stderrIsTTY := io.IsStderrTTY()
513
514 if stdoutIsTTY && stderrIsTTY {
515 io.progressIndicatorEnabled = true
516 }
517
518 if stdoutIsTTY && hasAlternateScreenBuffer(terminal.IsTrueColorSupported()) {
519 io.alternateScreenBufferEnabled = true
520 }
521
522 return io
523}
524
525type fakeTerm struct{}
526

Callers 2

MainFunction · 0.92
newIOStreamsFunction · 0.92

Calls 5

IsStdoutTTYMethod · 0.95
IsStderrTTYMethod · 0.95
hasAlternateScreenBufferFunction · 0.70
FdMethod · 0.65
IsTrueColorSupportedMethod · 0.65

Tested by

no test coverage detected