dive-zfs/cmd/version.go
Nguyen Ngoc Trung (Steven) 5dfd9fb9e8 Support version printout (#37)
2018-10-24 21:00:53 -04:00

35 lines
538 B
Go

package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
type Version struct {
Version string
Commit string
BuildTime string
}
var version *Version
// versionCmd represents the version command
var versionCmd = &cobra.Command{
Use: "version",
Short: "print the version number and exit (also --version)",
Run: printVersion,
}
func init() {
rootCmd.AddCommand(versionCmd)
}
func SetVersion(v *Version) {
version = v
}
func printVersion(cmd *cobra.Command, args []string) {
fmt.Printf("dive %s\n", version.Version)
}