-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharg.go
60 lines (49 loc) · 1 KB
/
arg.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
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"os"
"sort"
"github.com/urfave/cli"
)
func arg() *cli.App {
app := cli.NewApp()
app.Name = `wstail`
app.Usage = `convert "tail -f" as websocket output`
app.Version = version
app.UsageText = app.Name + ` [OPTION]...`
app.Authors = []cli.Author{
cli.Author{
Name: `Zheng Kai`,
Email: `[email protected]`,
},
}
app.HideHelp = true
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "config, c",
Usage: "Load configuration from `FILE`",
Value: configFileName,
},
cli.StringFlag{
Name: "whitelist, w",
Usage: "Load whitelist from `FILE`",
Value: whitelistFileName,
},
cli.StringFlag{
Name: "listen, l",
Usage: "WebSocket HTTP listen `ADDRESS`",
Value: httpListen,
},
}
sort.Sort(cli.FlagsByName(app.Flags))
app.Flags = append(
app.Flags,
cli.BoolFlag{
Name: "help, h",
Usage: "show this help message and exit",
},
)
app.Run(os.Args)
set := flag.NewFlagSet("contrive", 0)
nc := cli.NewContext(app, set, c)
return arg
}