MCPcopy Create free account
hub / github.com/cli/cli / System

Function System

pkg/iostreams/iostreams.go:510–557  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

508}
509
510func System() *IOStreams {
511 terminal := ghTerm.FromEnv()
512
513 var stdout fileWriter = os.Stdout
514 // On Windows with no virtual terminal processing support, translate ANSI escape
515 // sequences to console syscalls.
516 if colorableStdout := colorable.NewColorable(os.Stdout); colorableStdout != os.Stdout {
517 // Ensure that the file descriptor of the original stdout is preserved.
518 stdout = &fdWriter{
519 fd: os.Stdout.Fd(),
520 Writer: colorableStdout,
521 }
522 }
523
524 var stderr fileWriter = os.Stderr
525 // On Windows with no virtual terminal processing support, translate ANSI escape
526 // sequences to console syscalls.
527 if colorableStderr := colorable.NewColorable(os.Stderr); colorableStderr != os.Stderr {
528 // Ensure that the file descriptor of the original stderr is preserved.
529 stderr = &fdWriter{
530 fd: os.Stderr.Fd(),
531 Writer: colorableStderr,
532 }
533 }
534
535 io := &IOStreams{
536 In: os.Stdin,
537 Out: stdout,
538 ErrOut: stderr,
539 pagerCommand: os.Getenv("PAGER"),
540 term: &terminal,
541 sanitizeContent: true,
542 }
543 io.ContentOut = newContentWriter(io.Out, io.sanitizeContent)
544
545 stdoutIsTTY := io.IsStdoutTTY()
546 stderrIsTTY := io.IsStderrTTY()
547
548 if stdoutIsTTY && stderrIsTTY {
549 io.progressIndicatorEnabled = true
550 }
551
552 if stdoutIsTTY && hasAlternateScreenBuffer(terminal.IsTrueColorSupported()) {
553 io.alternateScreenBufferEnabled = true
554 }
555
556 return io
557}
558
559type fakeTerm struct{}
560

Callers 2

MainFunction · 0.92
newIOStreamsFunction · 0.92

Calls 6

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

Tested by

no test coverage detected