Add version flag which displays the current version.

This commit is contained in:
Michael van Tricht 2016-11-08 14:28:15 +01:00
parent d6585029d6
commit 219d9ed592
2 changed files with 7 additions and 1 deletions

View file

@ -6,7 +6,7 @@ combined:
go install . go install .
release: tag release-deps dockerhub release: tag release-deps dockerhub
gox -output="build/{{.Dir}}_{{.OS}}_{{.Arch}}" . gox -ldflags "-X main.version=${VERSION}" -output="build/{{.Dir}}_{{.OS}}_{{.Arch}}" .
fmt: fmt:
go fmt ./... go fmt ./...

View file

@ -25,6 +25,7 @@ var apiconf *cfgapi.Config
var uiconf *cfgui.Config var uiconf *cfgui.Config
var comconf *cfgcom.Config var comconf *cfgcom.Config
var exitCh chan int var exitCh chan int
var version string
func configure() { func configure() {
cfgcom.RegisterFlags() cfgcom.RegisterFlags()
@ -40,6 +41,11 @@ func configure() {
} }
func main() { func main() {
if len(os.Args) > 1 && (os.Args[1] == "-version" || os.Args[1] == "--version") {
fmt.Println("MailHog version: " + version)
os.Exit(0)
}
if len(os.Args) > 1 && os.Args[1] == "sendmail" { if len(os.Args) > 1 && os.Args[1] == "sendmail" {
args := os.Args args := os.Args
os.Args = []string{args[0]} os.Args = []string{args[0]}