diff --git a/.gitignore b/.gitignore index 64e4d8b..42ac027 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,4 @@ go.work go.work.sum # build -ass +ass_v* diff --git a/args.go b/args.go index 8edf2a8..545bffe 100644 --- a/args.go +++ b/args.go @@ -5,6 +5,7 @@ package main import ( "flag" + "fmt" ) var configFilepath string @@ -12,6 +13,15 @@ var privateKeyFilepath string var logFlag bool func ParseCommandline() bool { + flag.Usage = func () { + fmt.Println(`Usage: ass -config -pkey [-log] + + -config The path to the config file (required) + -pkey The path to the private key file (required) + -log Enable logging of messages + +version:`, Version) + } flag.StringVar(&configFilepath, "config", "", "The path to the config file (required)") flag.StringVar(&privateKeyFilepath, "pkey", "", "The path to the private key file (required)") flag.BoolVar(&logFlag, "log", false, "Enable logging of messages") diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..c367ae3 --- /dev/null +++ b/build.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +ver="$(git rev-parse --short HEAD)" + +if ! git diff-index --quiet HEAD +then + ver="${ver}-dev" +fi + +go build -ldflags="-X 'main.Version=${ver}'" -o ass_v${ver} diff --git a/main.go b/main.go index b4cf468..1a180a9 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,8 @@ package main import "os" +var Version = "dev" + func main() { if ParseCommandline() { ParseConfig(configFilepath)