blob: a7edcef6f973b34fa6fe56aaf0816c82c7d6406b [file] [log] [blame]
/*
Copyright © 2021 Aspect Build Systems
Not licensed for re-use
*/
package cmd
import (
"aspect.build/cli/bazel"
"aspect.build/cli/buildinfo"
"fmt"
"github.com/spf13/cobra"
)
// versionCmd represents the version command
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version of aspect CLI as well as tools it invokes",
Long: `Prints version info on colon-separated lines, just like bazel does`,
Run: func(cmd *cobra.Command, args []string) {
if !buildinfo.IsStamped() {
fmt.Println("Aspect version: not built with --stamp")
} else {
version := buildinfo.Release
if buildinfo.GitStatus != "clean" {
version += " (in a dirty clone)"
}
fmt.Printf("Aspect version: %s\n", version)
}
bazel.Spawn("version")
},
}
func init() {
rootCmd.AddCommand(versionCmd)
}