diff --git a/Makefile b/Makefile index f16456ac..c0252fd0 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ combined: go install . release: tag release-deps dockerhub - gox -output="build/{{.Dir}}_{{.OS}}_{{.Arch}}" . + gox -ldflags "-X main.version=${VERSION}" -output="build/{{.Dir}}_{{.OS}}_{{.Arch}}" . fmt: go fmt ./... diff --git a/main.go b/main.go index df528325..5e92f243 100644 --- a/main.go +++ b/main.go @@ -25,6 +25,7 @@ var apiconf *cfgapi.Config var uiconf *cfgui.Config var comconf *cfgcom.Config var exitCh chan int +var version string func configure() { cfgcom.RegisterFlags() @@ -40,6 +41,11 @@ func configure() { } 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" { args := os.Args os.Args = []string{args[0]}