git-roast/cmd/version.go

25 lines
388 B
Go
Raw Normal View History

2025-01-05 06:30:54 +01:00
package cmd
import (
"fmt"
"runtime/debug"
"github.com/spf13/cobra"
)
var versionCmd = &cobra.Command{
Use: "version",
Short: "print the program version",
Run: func(cmd *cobra.Command, args []string) {
if info, ok := debug.ReadBuildInfo(); ok {
fmt.Println(info.Main.Version)
} else {
fmt.Println("(devel)")
}
},
}
func init() {
rootCmd.AddCommand(versionCmd)
}