-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharguments.go
63 lines (52 loc) · 1.37 KB
/
arguments.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
57
58
59
60
61
62
63
package main
import (
"fmt"
"os"
"github.com/akamensky/argparse"
)
var arguments = struct {
Output string
StartID int
StopID int
Concurrency int
Verbose bool
}{}
func parseArgs(args []string) {
// Create new parser object
parser := argparse.NewParser("TenorArchiver", "Tenor.com archiver")
// Create flags
output := parser.String("o", "output", &argparse.Options{
Required: false,
Help: "Output directory",
Default: "Downloads/"})
startID := parser.Int("", "start-id", &argparse.Options{
Required: false,
Help: "First ID to scrape",
Default: 1})
stopID := parser.Int("", "stop-id", &argparse.Options{
Required: false,
Help: "Last ID to scrape",
Default: 10000000000})
concurrency := parser.Int("j", "concurrency", &argparse.Options{
Required: false,
Help: "Concurrency",
Default: 4})
verbose := parser.Flag("v", "verbose", &argparse.Options{
Required: false,
Help: "Verbose output",
Default: false})
// Parse input
err := parser.Parse(args)
if err != nil {
// In case of error print error and print usage
// This can also be done by passing -h or --help flags
fmt.Print(parser.Usage(err))
os.Exit(0)
}
// Fill arguments structure
arguments.Output = *output
arguments.Concurrency = *concurrency
arguments.StartID = *startID
arguments.StopID = *stopID
arguments.Verbose = *verbose
}