Skip to content

Commit

Permalink
Merge pull request #83 from Virtomize/feat/version
Browse files Browse the repository at this point in the history
feat: version flag
  • Loading branch information
c-seeger authored Dec 18, 2023
2 parents 89571b3 + 67da613 commit 51c6a0f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 16 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ Just clone the repo and run `mage build`, you can find the binary under `bin/mai
- configure your filters
- run Mail2Most `./mail2most` or with config path `./mail2most -c conf/mail2most.conf`

# Version Info

- run `./mail2most -version` to get current version information

## example conf - filter descriptions

**just configure the filters you need if a filter is not defined it is not used !**
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
github.com/go-ldap/ldap v3.0.3+incompatible // indirect
github.com/golang/protobuf v1.3.2 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/gopherjs/gopherjs v0.0.0-20191106031601-ce3c9ade29de // indirect
github.com/gorilla/websocket v1.4.2 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
Expand Down Expand Up @@ -436,7 +437,6 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
Expand Down
17 changes: 5 additions & 12 deletions lib/const.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
package mail2most

const (
// ERROR .
ERROR string = "error"
// INFO .
INFO string = "info"
// DEBUG .
DEBUG string = "debug"
// LOGSTDOUT .
LOGSTDOUT string = "stdout"
// LOGFILE .
LOGFILE string = "logfile"
// LOGFORMATJSON .
ERROR string = "error"
INFO string = "info"
DEBUG string = "debug"
LOGSTDOUT string = "stdout"
LOGFILE string = "logfile"
LOGFORMATJSON string = "json"
// LOGFORMATTEXT .
LOGFORMATTEXT string = "text"
)
7 changes: 5 additions & 2 deletions magefile.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build mage
//go:build mage
// +build mage

package main

Expand Down Expand Up @@ -34,7 +35,9 @@ func Build() error {
return err
}

return sh.RunV("go", "build", "-a", "-tags", "netgo", "-o", binPath+"/"+binName, "-ldflags", "-w -extldflags \"-static\"")
tag, _ := exec.Command("bash", "-c", "git tag --sort=-version:refname | head -n 1").Output()

return sh.RunV("go", "build", "-a", "-tags", "netgo", "-o", binPath+"/"+binName, "-ldflags", "-w -extldflags \"-static\" -X 'main.Version="+string(tag)+"'")
}

// CreateRelease - mage build
Expand Down
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,32 @@ package main

import (
"flag"
"fmt"
"log"

m2m "github.com/virtomize/mail2most/lib"
)

var Version string

func main() {
confFile := flag.String("c", "conf/mail2most.conf", "path to config file")
version := flag.Bool("version", false, "display mail2most version")
flag.Parse()

m, err := m2m.New(*confFile)
if err != nil {
log.Fatal(err)
}

if *version {
if Version == "" {
fmt.Print("unknown")
}
fmt.Print(Version)
return
}

err = m.Run()
if err != nil {
log.Fatal(err)
Expand Down

0 comments on commit 51c6a0f

Please sign in to comment.