Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version flag which displays the current version. #122

Merged
merged 1 commit into from
Nov 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./...
Expand Down
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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]}
Expand Down