@@ -27,6 +27,7 @@ import (
2727 "log"
2828 "os"
2929 "reflect"
30+ "runtime"
3031 "sort"
3132 "strconv"
3233 "strings"
@@ -37,6 +38,8 @@ import (
3738 "golang.org/x/tools/go/types/typeutil"
3839)
3940
41+ const buildVersion = "0.5.0"
42+
4043func main () {
4144 subcommands .Register (subcommands .CommandsCommand (), "" )
4245 subcommands .Register (subcommands .FlagsCommand (), "" )
@@ -45,6 +48,7 @@ func main() {
4548 subcommands .Register (& diffCmd {}, "" )
4649 subcommands .Register (& genCmd {}, "" )
4750 subcommands .Register (& showCmd {}, "" )
51+ subcommands .Register (& versionCmd {}, "" )
4852 flag .Parse ()
4953
5054 // Initialize the default logger to log to stderr.
@@ -64,6 +68,7 @@ func main() {
6468 "diff" : true ,
6569 "gen" : true ,
6670 "show" : true ,
71+ "version" : true ,
6772 }
6873 // Default to running the "gen" command.
6974 if args := flag .Args (); len (args ) == 0 || ! allCmds [args [0 ]] {
@@ -607,3 +612,22 @@ func logErrors(errs []error) {
607612 log .Println (strings .Replace (err .Error (), "\n " , "\n \t " , - 1 ))
608613 }
609614}
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