-
Notifications
You must be signed in to change notification settings - Fork 14
/
version.go
46 lines (35 loc) · 1018 Bytes
/
version.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
package version
import (
"fmt"
"github.com/gardener/landscapercli/pkg/version"
"github.com/spf13/cobra"
)
func NewVersionCommand() *cobra.Command {
return &cobra.Command{
Use: "version",
Aliases: []string{"v"},
Short: "displays the version",
Run: func(cmd *cobra.Command, args []string) {
v := version.Get()
fmt.Printf("\nLandscaper-CLI Version: %s\n", v.GitVersion)
if v.GitCommit != "" {
fmt.Printf(" GitCommit: %s\n", v.GitCommit)
}
if v.GitTreeState != "" {
fmt.Printf(" GitTreeState: %s\n", v.GitTreeState)
}
if v.GoVersion != "" {
fmt.Printf(" GoVersion: %s\n", v.GoVersion)
}
if v.Compiler != "" {
fmt.Printf(" Compiler: %s\n", v.Compiler)
}
if v.Platform != "" {
fmt.Printf(" Platform: %s\n", v.Platform)
}
fmt.Printf("\nCompatible Landscaper Version: %s", version.LandscaperGitVersion)
fmt.Printf("\nCompatible and included Component-Cli Version: %s", version.ComponentCliVersion)
fmt.Printf("\n\n")
},
}
}