-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
94 lines (80 loc) · 2.12 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package main
import (
"fmt"
"os"
"sort"
"github.com/dragosh/zen/cmd"
doc "github.com/dragosh/zen/cmd/doc"
"github.com/dragosh/zen/pkg/api"
"github.com/urfave/cli/v2"
)
const (
Version = "0.0.0"
Revision = "000001"
Name = "zen"
Usage = "Command Description"
)
var Commands []*cli.Command
func main() {
// EXAMPLE: Override a template
cli.AppHelpTemplate = `
⊹╰(⌣ʟ⌣)╯⊹
NAME:
{{.Name}} - {{.Usage}}
USAGE:
{{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}
{{if len .Authors}}
AUTHOR:
{{range .Authors}}{{ . }}{{end}}
{{end}}{{if .Commands}}
COMMANDS:
{{range .Commands}}{{if not .HideHelp}} {{join .Names ", "}}{{ "\t"}}{{.Usage}}{{ "\n" }}{{end}}{{end}}{{end}}{{if .VisibleFlags}}
GLOBAL OPTIONS:
{{range .VisibleFlags}}{{.}}
{{end}}{{end}}{{if .Copyright }}
COPYRIGHT:
{{.Copyright}}
{{end}}{{if .Version}}
VERSION:
{{.Version}}
{{end}}
`
cli.VersionPrinter = func(c *cli.Context) {
fmt.Printf("version=%s revision=%s\n", c.App.Version, Revision)
}
Commands = append(Commands, cmd.Doc())
// Commands = append(Commands, doc.Preview())
app := &cli.App{
EnableBashCompletion: true,
Version: Version,
Name: Name,
Usage: Usage,
Commands: Commands,
Action: doc.PreviewAction,
Flags: []cli.Flag{
// &cli.BoolFlag{
// Name: "no-color",
// Usage: "disable color output",
// EnvVars: []string{"NO_COLOR"},
// },
// &cli.StringFlag{
// Name: "log-level",
// Usage: "set log level, use \"DEBUG\" for more informations",
// Value: api.LOG_LEVEL,
// EnvVars: []string{"LOG_LEVEL"},
// },
&cli.StringFlag{
Name: "app-layout",
Value: "markdown",
DefaultText: "Static application layout",
Aliases: []string{"a"},
Usage: "Application layout",
},
},
}
sort.Sort(cli.FlagsByName(app.Flags))
sort.Sort(cli.CommandsByName(app.Commands))
if err := app.Run(os.Args); err != nil {
api.Log.Fatal(err)
}
}