2016-08-23 08:31:50 +08:00
package main
import (
"fmt"
"log"
2017-09-15 21:59:43 +08:00
"os"
2020-10-10 22:34:04 +08:00
"runtime/debug"
2016-08-26 14:51:31 +08:00
"strconv"
"time"
2016-08-23 08:31:50 +08:00
2020-04-15 04:47:30 +08:00
"github.com/StackExchange/dnscontrol/v3/commands"
_ "github.com/StackExchange/dnscontrol/v3/providers/_all"
2016-08-23 08:31:50 +08:00
)
2017-09-15 04:13:17 +08:00
//go:generate go run build/generate/generate.go build/generate/featureMatrix.go
2016-08-23 08:31:50 +08:00
func main ( ) {
log . SetFlags ( log . LstdFlags | log . Lshortfile )
2020-10-10 22:34:04 +08:00
if info , ok := debug . ReadBuildInfo ( ) ; ! ok && info == nil {
fmt . Fprint ( os . Stderr , "Warning: dnscontrol was built without Go modules. See https://github.com/StackExchange/dnscontrol#from-source for more information on how to build dnscontrol correctly.\n\n" )
}
2017-09-15 21:59:43 +08:00
os . Exit ( commands . Run ( versionString ( ) ) )
2016-08-23 08:31:50 +08:00
}
2020-07-14 19:20:07 +08:00
// Version management. Goals:
2016-08-26 14:51:31 +08:00
// 1. Someone who just does "go get" has at least some information.
2017-09-13 22:00:41 +08:00
// 2. If built with build/build.go, more specific build information gets put in.
2016-08-26 14:51:31 +08:00
// Update the number here manually each release, so at least we have a range for go-get people.
var (
SHA = ""
2020-09-04 22:49:23 +08:00
Version = "3.3.0"
2016-08-26 14:51:31 +08:00
BuildTime = ""
)
2016-08-23 08:31:50 +08:00
// printVersion prints the version banner.
2016-08-26 14:51:31 +08:00
func versionString ( ) string {
var version string
2016-08-23 08:31:50 +08:00
if SHA != "" {
2016-08-26 14:51:31 +08:00
version = fmt . Sprintf ( "%s (%s)" , Version , SHA )
} else {
2018-01-10 01:53:16 +08:00
version = fmt . Sprintf ( "%s-dev" , Version ) // no SHA. '0.x.y-dev' indicates it is run from source without build script.
2016-08-23 08:31:50 +08:00
}
2020-10-10 22:34:04 +08:00
if info , ok := debug . ReadBuildInfo ( ) ; ! ok && info == nil {
version += " (non-modules)"
}
2016-08-23 08:31:50 +08:00
if BuildTime != "" {
2016-08-26 14:51:31 +08:00
i , err := strconv . ParseInt ( BuildTime , 10 , 64 )
if err == nil {
tm := time . Unix ( i , 0 )
version += fmt . Sprintf ( " built %s" , tm . Format ( time . RFC822 ) )
}
2016-08-23 08:31:50 +08:00
}
2016-08-26 14:51:31 +08:00
return fmt . Sprintf ( "dnscontrol %s" , version )
2016-08-23 08:31:50 +08:00
}