Skip to content

Commit 6b81af5

Browse files
committed
cli: Add -version flag and output
1 parent b60383e commit 6b81af5

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

cmd/gdqcli/main.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func main() {
2020
platform := flag.Bool("show-platform", false, "show platform in the output")
2121
format := flag.String("format", "table", "one of table or json")
2222
edition := flag.String("edition", "", "GDQ edition to query. This can be a string or a schedule number and when omitted will result in the current/upcoming schedule being used")
23-
23+
showVersion := flag.Bool("version", false, "show CLI version and build info")
2424
flag.Usage = func() {
2525
fmt.Fprintf(flag.CommandLine.Output(), "Usage of %s:\n", os.Args[0])
2626
flag.PrintDefaults()
@@ -32,6 +32,11 @@ func main() {
3232

3333
flag.Parse()
3434

35+
if *showVersion {
36+
fmt.Fprintf(os.Stdout, "{\"version\": \"%s\", \"commit\": \"%s\", \"date\": \"%s\"}\n", version, commit, date)
37+
os.Exit(0)
38+
}
39+
3540
var ed gdq.Edition
3641
if *edition == "" {
3742
ed = gdq.Latest

cmd/gdqcli/version.go

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package main
2+
3+
var (
4+
version = "main"
5+
commit = "none"
6+
date = "unknown"
7+
)

0 commit comments

Comments
 (0)