dnscontrol/main.go
Tom Limoncelli 94aeff8489 Release v2.9
2019-05-27 15:56:57 -04:00

48 lines
1.2 KiB
Go

package main
import (
"fmt"
"log"
"os"
"strconv"
"time"
"github.com/StackExchange/dnscontrol/commands"
_ "github.com/StackExchange/dnscontrol/providers/_all"
)
//go:generate go run build/generate/generate.go build/generate/featureMatrix.go
func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
os.Exit(commands.Run(versionString()))
}
// Version management. 2 Goals:
// 1. Someone who just does "go get" has at least some information.
// 2. If built with build/build.go, more specific build information gets put in.
// Update the number here manually each release, so at least we have a range for go-get people.
var (
SHA = ""
Version = "2.9"
BuildTime = ""
)
// printVersion prints the version banner.
func versionString() string {
var version string
if SHA != "" {
version = fmt.Sprintf("%s (%s)", Version, SHA)
} else {
version = fmt.Sprintf("%s-dev", Version) // no SHA. '0.x.y-dev' indicates it is run from source without build script.
}
if BuildTime != "" {
i, err := strconv.ParseInt(BuildTime, 10, 64)
if err == nil {
tm := time.Unix(i, 0)
version += fmt.Sprintf(" built %s", tm.Format(time.RFC822))
}
}
return fmt.Sprintf("dnscontrol %s", version)
}