mirror of
https://github.com/ericchiang/pup
synced 2025-01-15 02:00:55 +00:00
parent
681d7bb639
commit
76da365ad3
@ -16,6 +16,10 @@ func init() {
|
||||
color.Output = colorable.NewColorableStdout()
|
||||
}
|
||||
|
||||
func ForcePrintColor(mode bool) {
|
||||
color.NoColor = !mode
|
||||
}
|
||||
|
||||
type Displayer interface {
|
||||
Display([]*html.Node)
|
||||
}
|
||||
|
17
parse.go
17
parse.go
@ -49,7 +49,7 @@ func PrintHelp(w io.Writer, exitCode int) {
|
||||
Version
|
||||
%s
|
||||
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
|
||||
-h --help display this help
|
||||
-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 {
|
||||
case "-c", "--color":
|
||||
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":
|
||||
pupEscapeHTML = false
|
||||
case "--pre":
|
||||
|
Loading…
Reference in New Issue
Block a user