-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoptions.go
37 lines (32 loc) · 801 Bytes
/
options.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
package main
import (
"flag"
"os"
"time"
)
var (
container string
id string
domainName string
interval time.Duration
host string
version string
)
func init() {
flag.StringVar(&container, "c", "", "Name of the container to restart")
flag.StringVar(&id, "id", "", "ID of the container to restart")
flag.StringVar(&domainName, "d", "", "Domain name to watch IP change")
flag.DurationVar(&interval, "t", time.Duration(10*time.Second),
"Time interval to check IP change on domain name")
flag.StringVar(&host, "h", "unix:///var/run/docker.sock",
"Docker server host")
flag.StringVar(&version, "v", "1.40", "Docker API version")
flag.Parse()
validate()
}
func validate() {
if (container == "" && id == "") || domainName == "" {
flag.Usage()
os.Exit(1)
}
}