diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..ca512e5 --- /dev/null +++ b/build.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +VERSION=0.1 +DATE=`date -u '+%Y-%m-%d_%H:%M:%S'` + +build() { + go build -o azure-sb-cli$EXT -ldflags "-X main.buildVersion=$VERSION -X main.buildDate=$DATE" main.go +} +build +GOOS=windows GOARCH=386 EXT=.exe build \ No newline at end of file diff --git a/main.go b/main.go index 5684503..ddc94d7 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,9 @@ import ( "github.com/Azure/azure-service-bus-go" ) +var buildVersion = "unknown" +var buildDate="unknown" + const NullStr = "\xff" var logDebug = false @@ -151,8 +154,9 @@ func usage() { fmt.Println(`Usage: ` + os.Args[0] + ` Commands: - send - Sends messages to a queue. Reads standard input, sending each line as message, all in same session. + send - Sends messages to a queue. Reads standard input, sending each line as message, all in same session. receive - Receives messages, outputting them to standard output, message per line. + -v - Prints version info. Common options: -c Connection string @@ -169,6 +173,10 @@ Receive options: `) } +func printVersion() { + fmt.Println(os.Args[0] + " " + buildVersion + " (built " + buildDate + ")") +} + func main() { commonFlags := flag.NewFlagSet("common flags", flag.ExitOnError) connStrPtr := commonFlags.String("c", "", "Connection string") @@ -186,6 +194,9 @@ func main() { case "-h": usage() return + case "-v": + printVersion() + return case "receive": commonFlags.BoolVar(&prefixMsgWithSessionId, "p", false, "Prefix received messages with session id, separated with ':'") }