-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.go
54 lines (43 loc) · 1.07 KB
/
cli.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
package cmd
import (
"fmt"
"github.com/Xuanwo/go-locale"
"github.com/jedib0t/go-pretty/table"
"github.com/urfave/cli/v2"
"golang.org/x/text/language"
"golang.org/x/text/message"
)
var tableStyle = &table.Style{
Name: "StyleRounded",
Box: table.StyleBoxRounded,
Color: table.ColorOptionsDefault,
Options: table.OptionsDefault,
Title: table.TitleOptionsDefault,
}
var debugFlag *cli.BoolFlag = &cli.BoolFlag{Name: "debug", Usage: "Enable debugging", Value: false}
func withLocale() (p *message.Printer) {
tag, err := locale.Detect()
if err != nil {
tag = language.English
}
p = message.NewPrinter(tag)
return
}
func versionPrinter(c *cli.Context) {
fmt.Println(c.App.Version)
}
func New(version string) *cli.App {
subs := []*cli.Command{UpdateCmd(), ConvertCmd(), CountCmd()}
flags := []cli.Flag{debugFlag}
cli.VersionPrinter = versionPrinter
cmd := &cli.App{
Name: "oui",
Usage: "MAC Address CLI Toolkit",
Action: MainCmd,
Commands: subs,
Flags: flags,
Version: version,
HideVersion: false,
}
return cmd
}