1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

47 lines
1.1 KiB
Go
Raw Normal View History

2016-08-22 18:31:50 -06:00
package main
import (
"fmt"
"log"
2016-08-26 00:51:31 -06:00
"strconv"
"time"
2016-08-22 18:31:50 -06:00
"github.com/StackExchange/dnscontrol/commands"
_ "github.com/StackExchange/dnscontrol/providers/_all"
2016-08-22 18:31:50 -06:00
)
2017-03-12 16:41:11 -07:00
//go:generate go run build/generate/generate.go
2016-08-22 18:31:50 -06:00
func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
commands.Run(versionString())
2016-08-22 18:31:50 -06:00
}
2016-08-26 00:51:31 -06:00
// 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.
2016-08-26 00:51:31 -06:00
// Update the number here manually each release, so at least we have a range for go-get people.
var (
SHA = ""
Version = "0.2.0"
2016-08-26 00:51:31 -06:00
BuildTime = ""
)
2016-08-22 18:31:50 -06:00
// printVersion prints the version banner.
2016-08-26 00:51:31 -06:00
func versionString() string {
var version string
2016-08-22 18:31:50 -06:00
if SHA != "" {
2016-08-26 00:51:31 -06: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 fromm source without build script.
2016-08-22 18:31:50 -06:00
}
if BuildTime != "" {
2016-08-26 00:51:31 -06: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-22 18:31:50 -06:00
}
2016-08-26 00:51:31 -06:00
return fmt.Sprintf("dnscontrol %s", version)
2016-08-22 18:31:50 -06:00
}