-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
48 lines (43 loc) · 989 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
45
46
47
48
package main
import (
"fmt"
"os"
"regexp"
"github.com/guessi/cloudtrail-cli/cmd"
"github.com/guessi/cloudtrail-cli/pkg/constants"
"github.com/urfave/cli/v2"
)
func showVersion() {
r, _ := regexp.Compile(`v[0-9]\.[0-9]+\.[0-9]+`)
versionInfo := r.FindString(constants.GitVersion)
fmt.Println("cloudtrail-cli", versionInfo)
fmt.Println(" Git Commit:", constants.GitVersion)
fmt.Println(" Build with:", constants.GoVersion)
fmt.Println(" Build time:", constants.BuildTime)
}
func main() {
app := &cli.App{
Name: constants.NAME,
Usage: constants.USAGE,
Version: constants.GitVersion,
Flags: cmd.Flags,
Action: func(c *cli.Context) error {
cmd.Wrapper(c)
return nil
},
Commands: []*cli.Command{
{
Name: "version",
Aliases: []string{"v"},
Usage: "Print version number",
Action: func(cCtx *cli.Context) error {
showVersion()
return nil
},
},
},
}
if err := app.Run(os.Args); err != nil {
os.Exit(1)
}
}