mirror of
https://github.com/cheat/cheat.git
synced 2026-03-07 11:13:33 +01:00
Replace docopt-go with spf13/cobra, giving cheat a built-in `--completion` flag that dynamically generates shell completions for bash, zsh, fish, and powershell. This replaces the manually-maintained static completion scripts and resolves the root cause of multiple completion issues (#768, #705, #633, #632, #476). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
27 lines
560 B
Go
27 lines
560 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/mattn/go-isatty"
|
|
)
|
|
|
|
// Color indicates whether colorization should be applied to the output
|
|
func (c *Config) Color(forceColorize bool) bool {
|
|
|
|
// default to the colorization specified in the configs...
|
|
colorize := c.Colorize
|
|
|
|
// ... however, only apply colorization if we're writing to a tty...
|
|
if !isatty.IsTerminal(os.Stdout.Fd()) && !isatty.IsCygwinTerminal(os.Stdout.Fd()) {
|
|
colorize = false
|
|
}
|
|
|
|
// ... *unless* the --colorize flag was passed
|
|
if forceColorize {
|
|
colorize = true
|
|
}
|
|
|
|
return colorize
|
|
}
|