Skip to content

Commit

Permalink
Add a -version flag to Houndd (hound-search#362)
Browse files Browse the repository at this point in the history
This commit adds a `-version` flag to houndd. Running `houndd -version` prints the current version and exits.

Co-authored-by: Kartikay Shandil <kartikays@sahaj.ai>
  • Loading branch information
kartikay101 and kartikay-sahaj committed Oct 30, 2020
1 parent e876521 commit 06e14d9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
16 changes: 16 additions & 0 deletions cmds/houndd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"encoding/json"
"flag"
"fmt"
"log"
"net/http"
"os"
Expand All @@ -13,6 +14,7 @@ import (
"strings"
"syscall"

"github.com/blang/semver"
"github.com/hound-search/hound/api"
"github.com/hound-search/hound/config"
"github.com/hound-search/hound/searcher"
Expand Down Expand Up @@ -113,6 +115,14 @@ func runHttp(
return http.ListenAndServe(addr, m)
}

func getVersion() semver.Version {
return semver.Version{
Major: 0,
Minor: 3,
Patch: 0,
}
}

func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
info_log = log.New(os.Stdout, "", log.LstdFlags)
Expand All @@ -121,9 +131,15 @@ func main() {
flagConf := flag.String("conf", "config.json", "")
flagAddr := flag.String("addr", ":6080", "")
flagDev := flag.Bool("dev", false, "")
flagVer := flag.Bool("version", false, "Display version and exit")

flag.Parse()

if *flagVer {
fmt.Printf("houndd v%s", getVersion())
os.Exit(0)
}

var cfg config.Config
if err := cfg.LoadFromFile(*flagConf); err != nil {
panic(err)
Expand Down
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ module github.com/hound-search/hound

go 1.13

require github.com/go-bindata/go-bindata v3.1.2+incompatible // indirect
require (
github.com/blang/semver v3.5.1+incompatible
github.com/go-bindata/go-bindata v3.1.2+incompatible // indirect
)
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
github.com/blang/semver v1.1.0 h1:ol1rO7QQB5uy7umSNV7VAmLugfLRD+17sYJujRNYPhg=
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/go-bindata/go-bindata v1.0.0 h1:DZ34txDXWn1DyWa+vQf7V9ANc2ILTtrEjtlsdJRF26M=
github.com/go-bindata/go-bindata v3.1.2+incompatible h1:5vjJMVhowQdPzjE1LdxyFF7YFTXg5IgGVW4gBr5IbvE=
github.com/go-bindata/go-bindata v3.1.2+incompatible/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo=

0 comments on commit 06e14d9

Please sign in to comment.