Skip to content

Commit

Permalink
Merge pull request #122 from swordbeta/version-number-flag
Browse files Browse the repository at this point in the history
Add version flag which displays the current version.
  • Loading branch information
ian-kent committed Nov 14, 2016
2 parents 565314c + 219d9ed commit 899774f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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

0 comments on commit 899774f

Please sign in to comment.