-
Notifications
You must be signed in to change notification settings - Fork 0
/
flags.go
32 lines (27 loc) · 1007 Bytes
/
flags.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
package main
import (
"flag"
)
type Flags struct {
apikey string
file string
bulkFromFolder string
maxRoutines int
log bool
maxRetries int
}
func (f *Flags) parseFlags() {
apikey := flag.String("apikey", "", "You can pass the Tinify API key here instead of the .env file")
file := flag.String("file", "", "Compresses a single file providing the relative or absolute filepath")
bulkFromFolder := flag.String("bulkfromfolder", "", "Compresses all the files in a folder providing the relative or absolute path to the folder")
maxRoutines := flag.Int("maxroutines", 4, "Max number of routines to run concurrently")
log := flag.Bool("log", false, "Writes the generated log into a file")
maxRetries := flag.Int("maxretries", 2, "Max number of retries if a request to the Tinify API fails per file")
flag.Parse()
f.apikey = *apikey
f.file = *file
f.bulkFromFolder = *bulkFromFolder
f.maxRoutines = *maxRoutines
f.log = *log
f.maxRetries = *maxRetries
}