pull/157/merge
Paul Makovich 2 years ago committed by GitHub
commit 877ac3981d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -16,6 +16,10 @@ func init() {
color.Output = colorable.NewColorableStdout() color.Output = colorable.NewColorableStdout()
} }
func ForcePrintColor(mode bool) {
color.NoColor = !mode
}
type Displayer interface { type Displayer interface {
Display([]*html.Node) Display([]*html.Node)
} }

@ -49,7 +49,7 @@ func PrintHelp(w io.Writer, exitCode int) {
Version Version
%s %s
Flags Flags
-c --color print result with color -c --color [mode] print result with color; mode is never, auto (default), or always
-f --file file to read from -f --file file to read from
-h --help display this help -h --help display this help
-i --indent number of spaces to use for indent or character -i --indent number of spaces to use for indent or character
@ -87,6 +87,21 @@ func ProcessFlags(cmds []string) (nonFlagCmds []string, err error) {
switch cmd { switch cmd {
case "-c", "--color": case "-c", "--color":
pupPrintColor = true pupPrintColor = true
if (i+1) < len(cmds) { // `--color` is not tail arg
switch strings.ToLower(cmds[i+1]) {
case "never":
pupPrintColor = false
ForcePrintColor(false)
i++
case "auto":
// set by default
// see also https://github.com/fatih/color#disableenable-color
i++
case "always":
ForcePrintColor(true)
i++
}
}
case "-p", "--plain": case "-p", "--plain":
pupEscapeHTML = false pupEscapeHTML = false
case "--pre": case "--pre":

Loading…
Cancel
Save