forked from hashicorp/levant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversion.go
43 lines (34 loc) · 1.07 KB
/
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
package command
import (
"fmt"
"github.com/jrasell/levant/buildtime"
"github.com/mitchellh/cli"
)
// VersionCommand is a Command implementation that prints the version.
type VersionCommand struct {
Version string
VersionPrerelease string
UI cli.Ui
}
// Help provides the help information for the version command.
func (c *VersionCommand) Help() string {
return ""
}
// Synopsis is provides a brief summary of the version command.
func (c *VersionCommand) Synopsis() string {
return "Prints the Levant version"
}
// Run executes the version command.
func (c *VersionCommand) Run(_ []string) int {
v := fmt.Sprintf("Levant v%s", c.Version)
if c.VersionPrerelease != "" {
v = v + fmt.Sprintf("-%s", c.VersionPrerelease)
}
c.UI.Output(v)
c.UI.Output(fmt.Sprintf("Date: %s", buildtime.BuildDate))
c.UI.Output(fmt.Sprintf("Commit: %s", buildtime.GitCommit))
c.UI.Output(fmt.Sprintf("Branch: %s", buildtime.GitBranch))
c.UI.Output(fmt.Sprintf("State: %s", buildtime.GitState))
c.UI.Output(fmt.Sprintf("Summary: %s", buildtime.GitSummary))
return 0
}