-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunner.go
More file actions
36 lines (31 loc) · 700 Bytes
/
runner.go
File metadata and controls
36 lines (31 loc) · 700 Bytes
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
package main
import (
"flag"
"fmt"
"os"
)
func helpAndExit() {
fmt.Println("Expected 'geocode' or 'crawl' subcommands")
os.Exit(1)
}
func main() {
geocodeCmd := flag.NewFlagSet("geocode", flag.ExitOnError)
inFN := geocodeCmd.String("in", "portalData.json",
"File containing stable data.")
outFN := geocodeCmd.String("out", "geocoded.json",
"Target file for geocoded data.")
crawlerCmd := flag.NewFlagSet("crawl", flag.ExitOnError)
if len(os.Args) < 2 {
helpAndExit()
}
switch os.Args[1] {
case "geocode":
geocodeCmd.Parse(os.Args[2:])
Geocode(*inFN, *outFN)
case "crawl":
fmt.Println("Crawling portal...")
crawlerCmd.Parse(os.Args[2:])
default:
helpAndExit()
}
}