github.com/ezbercih/terraform@v0.1.1-0.20140729011846-3c33865e0839/command/version.go (about)

     1  package command
     2  
     3  import (
     4  	"bytes"
     5  	"fmt"
     6  )
     7  
     8  // VersionCommand is a Command implementation prints the version.
     9  type VersionCommand struct {
    10  	Meta
    11  
    12  	Revision          string
    13  	Version           string
    14  	VersionPrerelease string
    15  }
    16  
    17  func (c *VersionCommand) Help() string {
    18  	return ""
    19  }
    20  
    21  func (c *VersionCommand) Run(args []string) int {
    22  	var versionString bytes.Buffer
    23  
    24  	args = c.Meta.process(args)
    25  
    26  	fmt.Fprintf(&versionString, "Terraform v%s", c.Version)
    27  	if c.VersionPrerelease != "" {
    28  		fmt.Fprintf(&versionString, ".%s", c.VersionPrerelease)
    29  
    30  		if c.Revision != "" {
    31  			fmt.Fprintf(&versionString, " (%s)", c.Revision)
    32  		}
    33  	}
    34  
    35  	c.Ui.Output(versionString.String())
    36  	return 0
    37  }
    38  
    39  func (c *VersionCommand) Synopsis() string {
    40  	return "Prints the Terraform version"
    41  }