-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (34 loc) · 844 Bytes
/
main.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
package main
import (
"fmt"
"os"
"github.com/urfave/cli"
)
func cliInit() *cli.App {
app := cli.NewApp()
app.Name = "Phmod"
app.Description = "Translator for chmod strings, both digit and char representations."
app.Usage = "phmod [OPTION] <args>"
app.Version = "1.0.0"
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "long, l",
Usage: "Prints the result in verbose, human-readable format.",
},
}
cli.AppHelpTemplate = `{{.Name}}{{if .Description}} - {{.Description}}{{end}}
{{if .Usage}}Usage: {{.Usage}}{{end}}
{{if .VisibleFlags}}Options:
{{range $index, $option := .VisibleFlags}}{{if $index}}
{{end}}{{$option}}{{end}}{{end}}
`
app.Action = parse
return app
}
func main() {
app := cliInit()
if err := app.Run(os.Args); err != nil {
fmt.Println("Error - ", err, "\nUse -h for usage info")
os.Exit(1)
}
}