Browse Source

number displayer added back in and unescape renamed to plain

pull/32/head
Eric Chiang 8 years ago
parent
commit
f42ff6b393
  1. 7
      display.go
  2. 6
      parse.go

7
display.go

@ -288,3 +288,10 @@ func (j JSONDisplayer) Display(nodes []*html.Node) {
}
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

@ -54,7 +54,7 @@ Flags
-i --indent number of spaces to use for indent or character
-n --number print number of elements selected
-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
--version display version
`
@ -85,7 +85,7 @@ func ProcessFlags(cmds []string) (nonFlagCmds []string, err error) {
switch cmd {
case "-c", "--color":
pupPrintColor = true
case "-u", "--unescape":
case "-p", "--plain":
pupEscapeHTML = false
case "-f", "--file":
filename := cmds[i+1]
@ -117,6 +117,8 @@ func ProcessFlags(cmds []string) (nonFlagCmds []string, err error) {
case "--version":
fmt.Println(VERSION)
os.Exit(0)
case "-n", "--number":
pupDisplayer = NumDisplayer{}
default:
if cmd[0] == '-' {
return []string{}, fmt.Errorf("Unrecognized flag '%s'", cmd)

Loading…
Cancel
Save