-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathflag.go
More file actions
44 lines (42 loc) · 809 Bytes
/
flag.go
File metadata and controls
44 lines (42 loc) · 809 Bytes
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
package main
import (
"github.com/kardianos/service"
"github.com/urfave/cli"
"strings"
)
func getApp() *cli.App {
app := cli.NewApp()
app.Name = Name
app.HelpName = app.Name
app.Usage = app.Name + " -c config_file"
app.Version = Version
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "show help",
},
cli.VersionFlag,
cli.StringFlag{
Name: "config, c",
Usage: "set config file",
Value: "/etc/dohproxy.yml",
},
cli.StringFlag{
Name: "service, s",
Usage: "service " + strings.Join(service.ControlAction[:], ","),
},
cli.BoolFlag{
Name: "from-service",
Hidden: true,
},
}
app.Action = func(c *cli.Context) error {
if c.Bool("help") {
cli.ShowAppHelpAndExit(c, 0)
}
runApp(c)
return nil
}
app.HideHelp = true
return app
}