-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
50 lines (44 loc) · 1.1 KB
/
main.go
File metadata and controls
50 lines (44 loc) · 1.1 KB
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
package main
import (
"context"
"fmt"
"os"
"regexp"
"github.com/guessi/eks-ami-finder/cmd"
"github.com/guessi/eks-ami-finder/pkg/constants"
"github.com/urfave/cli/v3"
)
var versionRegex = regexp.MustCompile(`v[0-9]\.[0-9]+\.[0-9]+`)
func showVersion() {
versionInfo := versionRegex.FindString(constants.GitVersion)
fmt.Println("eks-ami-finder", versionInfo)
fmt.Println(" Git Commit:", constants.GitVersion)
fmt.Println(" Build with:", constants.GoVersion)
fmt.Println(" Build time:", constants.BuildTime)
}
func main() {
app := &cli.Command{
Name: constants.NAME,
Usage: constants.USAGE,
Version: constants.GitVersion,
Flags: cmd.Flags,
Action: func(ctx context.Context, c *cli.Command) error {
return cmd.Wrapper(ctx, c)
},
Commands: []*cli.Command{
{
Name: "version",
Aliases: []string{"v"},
Usage: "Print version number",
Action: func(context.Context, *cli.Command) error {
showVersion()
return nil
},
},
},
}
if err := app.Run(context.Background(), os.Args); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
}