github.com/hazelops/ize@v1.1.12-0.20230915191306-97d7c0e48f11/internal/commands/version.go (about) 1 package commands 2 3 import ( 4 "io" 5 "text/template" 6 7 "github.com/spf13/cobra" 8 ) 9 10 func NewVersionCmd() *cobra.Command { 11 cmd := &cobra.Command{ 12 Use: "version", 13 Short: "Show IZE version", 14 Run: func(cmd *cobra.Command, args []string) { 15 c := cmd.Parent() 16 _ = tmpl(c.OutOrStdout(), c.VersionTemplate(), c) 17 }, 18 } 19 20 return cmd 21 } 22 23 func tmpl(w io.Writer, text string, data interface{}) error { 24 t := template.New("top") 25 template.Must(t.Parse(text)) 26 return t.Execute(w, data) 27 }