trying to implement a version command

main
Nick Dumas 2 years ago
parent b22519cd96
commit 7c38d9ae71

@ -0,0 +1,33 @@
/*
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
*/
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
var (
Version, Tag string
)
// rootCmd represents the base command when called without any subcommands
var versionCmd = &cobra.Command{
Use: "version",
Short: "prints obp version info",
Long: `displays git tag and sha
`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("%s %s\n", Version, Tag)
},
}
func init() {
// Cobra also supports local flags, which will only run
// when this action is called directly.
// rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
rootCmd.AddCommand(versionCmd)
}

@ -10,5 +10,7 @@ var (
) )
func main() { func main() {
cmd.Version = Version
cmd.Tag = Tag
cmd.Execute() cmd.Execute()
} }

Loading…
Cancel
Save