mirror of
https://github.com/ericchiang/pup
synced 2025-01-15 02:00:55 +00:00
number displayer added back in and unescape renamed to plain
This commit is contained in:
parent
de53f12fa5
commit
f42ff6b393
@ -288,3 +288,10 @@ func (j JSONDisplayer) Display(nodes []*html.Node) {
|
|||||||
}
|
}
|
||||||
fmt.Printf("%s", data)
|
fmt.Printf("%s", data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Print the number of features returned
|
||||||
|
type NumDisplayer struct{}
|
||||||
|
|
||||||
|
func (d NumDisplayer) Display(nodes []*html.Node) {
|
||||||
|
fmt.Println(len(nodes))
|
||||||
|
}
|
||||||
|
6
parse.go
6
parse.go
@ -54,7 +54,7 @@ Flags
|
|||||||
-i --indent number of spaces to use for indent or character
|
-i --indent number of spaces to use for indent or character
|
||||||
-n --number print number of elements selected
|
-n --number print number of elements selected
|
||||||
-l --limit restrict number of levels printed
|
-l --limit restrict number of levels printed
|
||||||
-u --unescape don't escape html
|
-p --plain don't escape html
|
||||||
--charset specify the charset for pup to use
|
--charset specify the charset for pup to use
|
||||||
--version display version
|
--version display version
|
||||||
`
|
`
|
||||||
@ -85,7 +85,7 @@ func ProcessFlags(cmds []string) (nonFlagCmds []string, err error) {
|
|||||||
switch cmd {
|
switch cmd {
|
||||||
case "-c", "--color":
|
case "-c", "--color":
|
||||||
pupPrintColor = true
|
pupPrintColor = true
|
||||||
case "-u", "--unescape":
|
case "-p", "--plain":
|
||||||
pupEscapeHTML = false
|
pupEscapeHTML = false
|
||||||
case "-f", "--file":
|
case "-f", "--file":
|
||||||
filename := cmds[i+1]
|
filename := cmds[i+1]
|
||||||
@ -117,6 +117,8 @@ func ProcessFlags(cmds []string) (nonFlagCmds []string, err error) {
|
|||||||
case "--version":
|
case "--version":
|
||||||
fmt.Println(VERSION)
|
fmt.Println(VERSION)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
case "-n", "--number":
|
||||||
|
pupDisplayer = NumDisplayer{}
|
||||||
default:
|
default:
|
||||||
if cmd[0] == '-' {
|
if cmd[0] == '-' {
|
||||||
return []string{}, fmt.Errorf("Unrecognized flag '%s'", cmd)
|
return []string{}, fmt.Errorf("Unrecognized flag '%s'", cmd)
|
||||||
|
Loading…
Reference in New Issue
Block a user