command/version: use Meta

This commit is contained in:
Mitchell Hashimoto 2014-07-13 10:42:18 -07:00
parent 3a8606c117
commit dde0f0f8df
2 changed files with 7 additions and 5 deletions

View File

@ -3,24 +3,26 @@ package command
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"github.com/mitchellh/cli"
) )
// VersionCommand is a Command implementation prints the version. // VersionCommand is a Command implementation prints the version.
type VersionCommand struct { type VersionCommand struct {
Meta
Revision string Revision string
Version string Version string
VersionPrerelease string VersionPrerelease string
Ui cli.Ui
} }
func (c *VersionCommand) Help() string { func (c *VersionCommand) Help() string {
return "" return ""
} }
func (c *VersionCommand) Run(_ []string) int { func (c *VersionCommand) Run(args []string) int {
var versionString bytes.Buffer var versionString bytes.Buffer
args = c.Meta.process(args)
fmt.Fprintf(&versionString, "Terraform v%s", c.Version) fmt.Fprintf(&versionString, "Terraform v%s", c.Version)
if c.VersionPrerelease != "" { if c.VersionPrerelease != "" {
fmt.Fprintf(&versionString, ".%s", c.VersionPrerelease) fmt.Fprintf(&versionString, ".%s", c.VersionPrerelease)

View File

@ -71,10 +71,10 @@ func init() {
"version": func() (cli.Command, error) { "version": func() (cli.Command, error) {
return &command.VersionCommand{ return &command.VersionCommand{
Meta: meta,
Revision: GitCommit, Revision: GitCommit,
Version: Version, Version: Version,
VersionPrerelease: VersionPrerelease, VersionPrerelease: VersionPrerelease,
Ui: Ui,
}, nil }, nil
}, },
} }