Skip to content

Commit

Permalink
[ci skip] Add version for tagging
Browse files Browse the repository at this point in the history
  • Loading branch information
pcarranza committed Sep 23, 2018
1 parent fcacc13 commit 1cd35cc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Usage of ./propaganda:
match string regex (default "\\[announce\\]")
-metrics string
metrics path (default "/metrics")
-version
show version and exit
-webhook-url string
slack webhook url (default SLACK_WEBHOOK_URL env var)
```
12 changes: 10 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"gitlab.com/yakshaving.art/propaganda/metrics"
"gitlab.com/yakshaving.art/propaganda/server"
"gitlab.com/yakshaving.art/propaganda/slack"
"gitlab.com/yakshaving.art/propaganda/version"

"github.com/onrik/logrus/filename"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -85,8 +86,9 @@ type Args struct {
WebhookURL string
MatchString string

ConfigFile string
Debug bool
ConfigFile string
Debug bool
ShowVersion bool
}

func parseArgs() Args {
Expand All @@ -98,8 +100,14 @@ func parseArgs() Args {
flag.StringVar(&args.MatchString, "match-pattern", "\\[announce\\]", "match string")
flag.StringVar(&args.ConfigFile, "config", "propaganda.yml", "configuration file to use")
flag.BoolVar(&args.Debug, "debug", false, "enable debug logging")
flag.BoolVar(&args.ShowVersion, "version", false, "show version and exit")
flag.Parse()

if args.ShowVersion {
logrus.Printf("Version: %s Commit: %s Date: %s", version.Version, version.Commit, version.Date)
os.Exit(0)
}

if args.Debug {
toggleLogLevel()
}
Expand Down
13 changes: 13 additions & 0 deletions version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package version

// Name is the application name
var Name = "propaganda"

// Version is the application Version
var Version string

// Date is the built date and time
var Date string

// Commit is the commit in which the package is based
var Commit string

0 comments on commit 1cd35cc

Please sign in to comment.