// Package buildinfo exposes the RelSpec version and build date so that both the // CLI and the schema writers can stamp generated output with the same values. package buildinfo import ( "fmt" "runtime/debug" "time" ) // Version and BuildDate are set via -ldflags at build time (see Makefile). When // built without ldflags they are backfilled from the Go module build info. var ( Version = "dev" BuildDate = "unknown" ) func init() { if Version != "dev" { return } info, ok := debug.ReadBuildInfo() if !ok { return } var rev, vcsTime string for _, s := range info.Settings { switch s.Key { case "vcs.revision": if len(s.Value) >= 7 { rev = s.Value[:7] } case "vcs.time": vcsTime = s.Value } } if rev != "" { Version = rev } if t, err := time.Parse(time.RFC3339, vcsTime); err == nil { BuildDate = t.UTC().Format("2006-01-02 15:04:05 UTC") } } // GeneratedComment returns the one-line provenance string embedded in generated // files, e.g. "RelSpec dev (built: unknown)". func GeneratedComment() string { return fmt.Sprintf("RelSpec %s (built: %s)", Version, BuildDate) } const AsciiLogo = ` ██████╗ ███████╗██╗ ███████╗██████╗ ███████╗ ██████╗ ██╔══██╗██╔════╝██║ ██╔════╝██╔══██╗██╔════╝██╔════╝ ██████╔╝█████╗ ██║ ███████╗██████╔╝█████╗ ██║ ██╔══██╗██╔══╝ ██║ ╚════██║██╔═══╝ ██╔══╝ ██║ ██║ ██║███████╗███████╗███████║██║ ███████╗╚██████╗ ╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝╚═╝ ╚══════╝ ╚═════╝ [ IN ] ──▶ [ RELSPEC ] ──▶ [ OUT ] ╔══════════════════════════════════════╗ ║ ║ ║ © WARKY DEVS ║ ║ Author: Hein (hein@warky.dev) ║ ║ ║ ╚══════════════════════════════════════╝ `