52 lines
2.1 KiB
Go
52 lines
2.1 KiB
Go
|
|
package launcher
|
||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
"os"
|
||
|
|
"runtime/debug"
|
||
|
|
"strings"
|
||
|
|
|
||
|
|
"code.nochebuena.dev/einherjar/contracts/observability"
|
||
|
|
)
|
||
|
|
|
||
|
|
func printBanner(identifiables []observability.Identifiable) {
|
||
|
|
v := strings.ToLower(os.Getenv("EINHERJAR_BANNER"))
|
||
|
|
if v == "off" || v == "false" {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
fmt.Fprintf(os.Stdout, bannerText, coreVersion())
|
||
|
|
for _, id := range identifiables {
|
||
|
|
path := strings.TrimPrefix(id.ModulePath(), "code.nochebuena.dev/")
|
||
|
|
fmt.Fprintf(os.Stdout, " · %-25s %s\n", path, id.ModuleVersion())
|
||
|
|
}
|
||
|
|
if len(identifiables) > 0 {
|
||
|
|
fmt.Fprintln(os.Stdout)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func coreVersion() string {
|
||
|
|
const path = "code.nochebuena.dev/einherjar/core"
|
||
|
|
if info, ok := debug.ReadBuildInfo(); ok {
|
||
|
|
for _, dep := range info.Deps {
|
||
|
|
if dep.Path == path {
|
||
|
|
return dep.Version
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if info.Main.Path == path {
|
||
|
|
return info.Main.Version
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return "(devel)"
|
||
|
|
}
|
||
|
|
|
||
|
|
const bannerText = `
|
||
|
|
███████╗██╗███╗ ██╗██╗ ██╗███████╗██████╗ ██╗ █████╗ ██████╗
|
||
|
|
██╔════╝██║████╗ ██║██║ ██║██╔════╝██╔══██╗ ██║██╔══██╗██╔══██╗
|
||
|
|
█████╗ ██║██╔██╗ ██║███████║█████╗ ██████╔╝ ██║███████║██████╔╝
|
||
|
|
██╔══╝ ██║██║╚██╗██║██╔══██║██╔══╝ ██╔══██╗██ ██║██╔══██║██╔══██╗
|
||
|
|
███████╗██║██║ ╚████║██║ ██║███████╗██║ ██║╚█████╔╝██║ ██║██║ ██║
|
||
|
|
╚══════╝╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚════╝ ╚═╝ ╚═╝╚═╝ ╚═╝
|
||
|
|
code.nochebuena.dev/einherjar · Chosen warriors. Not for themselves. · %s
|
||
|
|
|
||
|
|
`
|