-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
72 lines (63 loc) · 1.41 KB
/
Copy pathmain.go
File metadata and controls
72 lines (63 loc) · 1.41 KB
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
64
65
66
67
68
69
70
71
72
package main
import (
"fmt"
"github.com/edwinhoksberg/docker-sync-hosts/command"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli"
"os"
)
var (
Name string
Version string
)
func main() {
command := new(command.Command)
app := cli.NewApp()
app.Name = Name
app.Usage = ""
app.HelpName = Name
app.Version = Version
app.Authors = []cli.Author{
{
Name: "Edwin Hoksberg",
Email: "mail@edwinhoksberg.nl",
},
}
app.UsageText = fmt.Sprintf(`A simple cli application to keep your hosts file up-to-date with running docker containers.
Homepage: https://github.com/edwinhoksberg/docker-sync-hosts`)
app.Commands = []cli.Command{
{
Name: "sync",
Usage: "Sync the hosts file with currently running docker containers",
Action: command.Sync,
},
{
Name: "daemon",
Usage: "Start a daemon to sync your hosts file when a container is started or stopped",
Action: command.Daemon,
},
}
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "socket",
Usage: "socket endpoint for docker",
Value: "unix:///var/run/docker.sock",
},
cli.StringFlag{
Name: "extension",
Usage: "the hostname extension to use",
Value: ".test",
},
cli.BoolFlag{
Name: "verbose",
Usage: "enable debug logging",
},
cli.BoolFlag{
Name: "quiet",
Usage: "completely disable logging",
},
}
if err := app.Run(os.Args); err != nil {
log.WithError(err).Error()
}
}