-
Notifications
You must be signed in to change notification settings - Fork 1
/
tagquery.go
56 lines (44 loc) · 1.08 KB
/
tagquery.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// status.go
package main
import (
"flag"
"fmt"
"log"
"os"
"strings"
"github.com/donomii/goof"
)
func search(terms []string, displayFingerprint bool) {
log.Println("Searching for", terms)
if len(terms) > 0 {
cmd := []string{"csearch", "-i", terms[0]}
res := goof.QC(cmd)
for _, t := range terms {
res = goof.Grep(t, res)
}
lines := strings.Split(res, "\n")
for _, v := range lines {
fmt.Printf("%v\n", v)
}
}
log.Println("Search complete")
}
var completeMatch = false
func main() {
var shutdown bool
fetchStatus := false
displayFingerprint := false
flag.BoolVar(&completeMatch, "completeMatch", false, "Do not return partial matches")
flag.BoolVar(&fetchStatus, "status", false, "Report status")
flag.BoolVar(&shutdown, "shutdown", false, "Shutdown the server")
flag.BoolVar(&displayFingerprint, "fingerprint", false, "Display the tag fingerprint for each result")
flag.Parse()
if shutdown {
os.Exit(0)
}
terms := flag.Args()
if len(terms) < 1 {
fmt.Println("Use: query.exe < --completeMatch > search terms")
}
search(terms, displayFingerprint)
}