aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorMitch Riedstra <mitch@riedstra.us>2019-09-22 06:19:25 -0400
committerMitch Riedstra <mitch@riedstra.us>2019-09-22 06:19:25 -0400
commit7ea49a4869751f93172f276737d094e55121a08d (patch)
treed35af679e4efbccb21217d9401a396ba09c18e57 /main.go
parente9a29c85c023e9a91027122bd361244db575d44b (diff)
downloadhook-7ea49a4869751f93172f276737d094e55121a08d.tar.gz
hook-7ea49a4869751f93172f276737d094e55121a08d.tar.xz
Add a build script, go mod file and update the readmev1.0
Diffstat (limited to 'main.go')
-rw-r--r--main.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/main.go b/main.go
index 8524518..b6bdd50 100644
--- a/main.go
+++ b/main.go
@@ -11,6 +11,10 @@ import (
"text/template"
)
+var (
+ versionString string
+)
+
type Hook struct {
Url string
Schema map[string]string
@@ -38,7 +42,7 @@ func readConf(fn string, cfg map[string]*Hook) error {
func help() {
n := os.Args[0]
- fmt.Fprintf(os.Stderr, `Usage: %s [-c CONFIG] -n HOOK_NAME [-v VarName VarVal]...
+ fmt.Fprintf(os.Stderr, `Usage: %s [-V -version] [-c CONFIG] -n HOOK_NAME [-v VarName VarVal]...
For example:
@@ -110,6 +114,11 @@ func (h *Hook) Post() (*http.Response, error) {
return resp, err
}
+func version() {
+ fmt.Println(versionString)
+ os.Exit(0)
+}
+
func main() {
cfgFN := ""
hookName := ""
@@ -126,6 +135,8 @@ func main() {
case "-v", "-var", "--var":
vars[os.Args[i+1]] = os.Args[i+2]
i += 2
+ case "-V", "-version", "--version":
+ version()
default:
help()
}