func do_count(p *pisearch.Pisearch) { if flag.NArg() < 2 { log.Fatal("use: pi count <string>") } searchstr := flag.Arg(1) fmt.Println(p.Count(searchstr)) }
func do_search(p *pisearch.Pisearch) { if flag.NArg() < 2 { log.Fatal("use: pi search <string> [startpos]") } searchstr := flag.Arg(1) startpos := 0 if flag.NArg() > 2 { startpos, _ = strconv.Atoi(flag.Arg(1)) } found, pos, nMatches := p.Search(startpos, searchstr) fmt.Println("Found: ", found) fmt.Println("Pos: ", pos) fmt.Println("nMatch: ", nMatches) }