-
Notifications
You must be signed in to change notification settings - Fork 3
/
flags.go
49 lines (39 loc) · 1.43 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"fmt"
"os"
"github.com/huawei-openlab/harbour/mflag"
"github.com/huawei-openlab/harbour/opts"
)
type command struct {
name string
description string
}
var (
flVersion = mflag.Bool([]string{"v", "-version"}, false, "Print version information and quit")
flDaemon = mflag.Bool([]string{"d", "-daemon"}, false, "Enable daemon mode")
flDockerSock = mflag.String([]string{"-docker-sock"}, opts.DEFAULTDOCKERSOCKET, "Path to docker sock file")
flRuntime = mflag.String([]string{"-container-runtime"}, opts.DEFAULTRUNTIME, "Container runtime to choose")
flDebug = mflag.Bool([]string{"D", "-debug"}, false, "Enable debug mode")
flGroup = mflag.String([]string{"G", "-group"}, "docker", "Group for the unix socket")
flHelp = mflag.Bool([]string{"h", "-help"}, false, "Print usage")
// these are initialized in init() below
flHosts []string
)
var (
commands = []command{}
)
func init() {
opts.HostListVar(&flHosts, []string{"H", "-host"}, "Daemon socket(s) to connect to")
mflag.Usage = func() {
fmt.Fprint(os.Stdout, "Usage: harbour [OPTIONS] [arg...]\n\nOptions:\n")
mflag.CommandLine.SetOutput(os.Stdout)
mflag.PrintDefaults()
help := "\nCommands:\n"
for _, cmd := range commands {
help += fmt.Sprintf(" %-10.10s%s\n", cmd.name, cmd.description)
}
help += "\nRun 'harbour COMMAND --help' for more information on a command."
fmt.Fprintf(os.Stdout, "%s\n", help)
}
}