dnscontrol/main.go

48 lines
1.2 KiB
Go
Raw Normal View History

2016-08-23 08:31:50 +08:00
package main
import (
"fmt"
"log"
"os"
2016-08-26 14:51:31 +08:00
"strconv"
"time"
2016-08-23 08:31:50 +08:00
"github.com/StackExchange/dnscontrol/v3/commands"
_ "github.com/StackExchange/dnscontrol/v3/providers/_all"
2016-08-23 08:31:50 +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)
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.
// 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-06-02 22:41:21 +08:00
Version = "3.2.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 {
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
}
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
}