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

Function System

pkg/iostreams/iostreams.go:511–558  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

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