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

Method DetectTerminalTheme

pkg/iostreams/iostreams.go:127–141  ·  view source on GitHub ↗

DetectTerminalTheme is a utility to call before starting the output pager so that the terminal background can be reliably detected.

()

Source from the content-addressed store, hash-verified

125// DetectTerminalTheme is a utility to call before starting the output pager so that the terminal background
126// can be reliably detected.
127func (s *IOStreams) DetectTerminalTheme() {
128 if !s.ColorEnabled() || s.pagerProcess != nil {
129 s.terminalTheme = "none"
130 return
131 }
132
133 style := os.Getenv("GLAMOUR_STYLE")
134 if style != "" && style != "auto" {
135 // ensure GLAMOUR_STYLE takes precedence over "light" and "dark" themes
136 s.terminalTheme = "none"
137 return
138 }
139
140 s.terminalTheme = s.term.Theme()
141}
142
143// TerminalTheme returns "light", "dark", or "none" depending on the background color of the terminal.
144func (s *IOStreams) TerminalTheme() string {

Callers 11

TerminalThemeMethod · 0.95
viewRunFunction · 0.80
listRunFunction · 0.80
viewRunFunction · 0.80
longPagerFunction · 0.80
viewRunFunction · 0.80
viewRunFunction · 0.80
viewRunFunction · 0.80
renderAllFilesFunction · 0.80
viewRunFunction · 0.80
runViewFunction · 0.80

Calls 2

ColorEnabledMethod · 0.95
ThemeMethod · 0.65

Tested by

no test coverage detected