@ -1,18 +1,16 @@
package command
import (
"bytes"
"fmt"
"github.com/hashicorp/packer/version"
)
// VersionCommand is a Command implementation prints the version.
type VersionCommand struct {
Meta
Revision string
Version string
VersionPrerelease string
CheckFunc VersionCheckFunc
CheckFunc VersionCheckFunc
}
// VersionCheckFunc is the callback called by the Version command to
@ -29,25 +27,15 @@ type VersionCheckInfo struct {
}
func ( c * VersionCommand ) Help ( ) string {
return " "
return " Prints the Packer version, and checks for new release. "
}
func ( c * VersionCommand ) Run ( args [ ] string ) int {
c . Ui . Machine ( "version" , c . Version )
c . Ui . Machine ( "version-prelease" , c . VersionPrerelease )
c . Ui . Machine ( "version-commit" , c . Revision )
var versionString bytes . Buffer
fmt . Fprintf ( & versionString , "Packer v%s" , c . Version )
if c . VersionPrerelease != "" {
fmt . Fprintf ( & versionString , "-%s" , c . VersionPrerelease )
if c . Revision != "" {
fmt . Fprintf ( & versionString , " (%s)" , c . Revision )
}
}
c . Ui . Machine ( "version" , version . Version )
c . Ui . Machine ( "version-prelease" , version . VersionPrerelease )
c . Ui . Machine ( "version-commit" , version . GitCommit )
c . Ui . Say ( versionString. String ( ) )
c . Ui . Say ( fmt . Sprintf ( "Packer v%s" , version . FormattedVersion ( ) ) )
// If we have a version check function, then let's check for
// the latest version as well.