-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
46 lines (36 loc) · 1.04 KB
/
main.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
package main
import (
"fmt"
"log"
"os"
"github.com/spf13/pflag"
)
func main() {
var (
verbose bool
ignoreReferrer bool
quiet bool
userAgent = defaultUserAgent()
)
pflag.BoolVarP(&verbose, "verbose", "v", false, "Show all requests including skipped.")
pflag.BoolVarP(&quiet, "quiet", "q", false, "Only show errors.")
pflag.BoolVarP(&ignoreReferrer, "ignore-referrer", "i", false, "Ignore referrer when checking for duplicate URLs.")
pflag.StringVar(&userAgent, "user-agent", userAgent, "HTTP User-Agent header to send. If empty, the default Go User-Agent will be used.")
pflag.Parse()
startURL := pflag.Arg(0)
if len(startURL) == 0 {
fmt.Println("Usage: linky [options] URL\n\nOptions:")
pflag.PrintDefaults()
return
}
fmt.Printf("URL: %s\n", startURL)
s, err := newSupervisor(startURL, verbose, quiet, ignoreReferrer)
if err != nil {
log.Fatalf("Error creating supervisor: %s", err)
}
newWorker(s.WorkerChan(), s.UpdateChan(), userAgent)
<-s.Done()
if showResults(s.Results()) > 0 {
os.Exit(1)
}
}