-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
79 lines (71 loc) · 1.38 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
package main
import (
"fmt"
"log"
"os"
"runtime"
"time"
"github.com/GoodwayGroup/rsgrants/info"
"github.com/clok/cdocs"
"github.com/urfave/cli/v2"
)
var version string
func main() {
// Generate the install-manpage command
im, err := cdocs.InstallManpageCommand(&cdocs.InstallManpageCommandInput{
AppName: info.AppName,
})
if err != nil {
log.Fatal(err)
}
app := &cli.App{
Name: info.AppName,
Version: version,
Compiled: time.Now(),
Authors: []*cli.Author{
{
Name: "Derek Smith",
Email: "[email protected]",
},
{
Name: info.AppRepoOwner,
},
},
Copyright: "(c) 2021 Goodway Group",
HelpName: info.AppName,
Usage: "AWS Redshift grants tool",
EnableBashCompletion: true,
Commands: []*cli.Command{
im,
{
Name: "version",
Aliases: []string{"v"},
Usage: "Print version info",
Action: func(c *cli.Context) error {
fmt.Printf("%s %s (%s/%s)\n", info.AppName, version, runtime.GOOS, runtime.GOARCH)
return nil
},
},
},
}
if os.Getenv("DOCS_MD") != "" {
docs, err := cdocs.ToMarkdown(app)
if err != nil {
panic(err)
}
fmt.Println(docs)
return
}
if os.Getenv("DOCS_MAN") != "" {
docs, err := cdocs.ToMan(app)
if err != nil {
panic(err)
}
fmt.Println(docs)
return
}
err = app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}