42 lines
771 B
Go
42 lines
771 B
Go
package command
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
)
|
|
|
|
// VersionCommand is a Command implementation prints the version.
|
|
type VersionCommand struct {
|
|
Meta
|
|
|
|
Revision string
|
|
Version string
|
|
VersionPrerelease string
|
|
}
|
|
|
|
func (c *VersionCommand) Help() string {
|
|
return ""
|
|
}
|
|
|
|
func (c *VersionCommand) Run(args []string) int {
|
|
var versionString bytes.Buffer
|
|
|
|
args = c.Meta.process(args, false)
|
|
|
|
fmt.Fprintf(&versionString, "Terraform v%s", c.Version)
|
|
if c.VersionPrerelease != "" {
|
|
fmt.Fprintf(&versionString, ".%s", c.VersionPrerelease)
|
|
|
|
if c.Revision != "" {
|
|
fmt.Fprintf(&versionString, " (%s)", c.Revision)
|
|
}
|
|
}
|
|
|
|
c.Ui.Output(versionString.String())
|
|
return 0
|
|
}
|
|
|
|
func (c *VersionCommand) Synopsis() string {
|
|
return "Prints the Terraform version"
|
|
}
|