@@ -27,6 +27,7 @@ import (
27
27
"log"
28
28
"os"
29
29
"reflect"
30
+ "runtime"
30
31
"sort"
31
32
"strconv"
32
33
"strings"
@@ -37,6 +38,8 @@ import (
37
38
"golang.org/x/tools/go/types/typeutil"
38
39
)
39
40
41
+ const buildVersion = "0.5.0"
42
+
40
43
func main () {
41
44
subcommands .Register (subcommands .CommandsCommand (), "" )
42
45
subcommands .Register (subcommands .FlagsCommand (), "" )
@@ -45,6 +48,7 @@ func main() {
45
48
subcommands .Register (& diffCmd {}, "" )
46
49
subcommands .Register (& genCmd {}, "" )
47
50
subcommands .Register (& showCmd {}, "" )
51
+ subcommands .Register (& versionCmd {}, "" )
48
52
flag .Parse ()
49
53
50
54
// Initialize the default logger to log to stderr.
@@ -64,6 +68,7 @@ func main() {
64
68
"diff" : true ,
65
69
"gen" : true ,
66
70
"show" : true ,
71
+ "version" : true ,
67
72
}
68
73
// Default to running the "gen" command.
69
74
if args := flag .Args (); len (args ) == 0 || ! allCmds [args [0 ]] {
@@ -607,3 +612,22 @@ func logErrors(errs []error) {
607
612
log .Println (strings .Replace (err .Error (), "\n " , "\n \t " , - 1 ))
608
613
}
609
614
}
615
+
616
+ type versionCmd struct {}
617
+
618
+ func (* versionCmd ) Name () string { return "version" }
619
+ func (* versionCmd ) Synopsis () string {
620
+ return "print Wire version"
621
+ }
622
+ func (* versionCmd ) Usage () string {
623
+ return `version
624
+
625
+ Version prints the build information for Go executables.
626
+
627
+ `
628
+ }
629
+ func (cmd * versionCmd ) SetFlags (f * flag.FlagSet ) {}
630
+ func (cmd * versionCmd ) Execute (ctx context.Context , f * flag.FlagSet , args ... interface {}) subcommands.ExitStatus {
631
+ fmt .Printf ("wire version %s %s/%s" , buildVersion , runtime .GOOS , runtime .GOARCH )
632
+ return subcommands .ExitSuccess
633
+ }
0 commit comments