Files
gh-lmorchard-lmorchard-agen…/skills/go-cli-builder/assets/templates/version.go.template
2025-11-30 08:37:58 +08:00

28 lines
528 B
Plaintext

package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
var (
version = "dev"
commit = "unknown"
date = "unknown"
)
// versionCmd represents the version command
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print version information",
Long: `Print the version, commit hash, and build date of this application.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("{{PROJECT_NAME}} %s (commit: %s, built: %s)\n", version, commit, date)
},
}
func init() {
rootCmd.AddCommand(versionCmd)
}