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

Method DetectTerminalTheme

pkg/iostreams/iostreams.go:128–142  ·  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

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

Callers 12

TerminalThemeMethod · 0.95
viewRunFunction · 0.80
listRunFunction · 0.80
viewRunFunction · 0.80
longPagerFunction · 0.80
viewRunFunction · 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