Skip to content
This repository was archived by the owner on Aug 25, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions cmd/wire/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"log"
"os"
"reflect"
"runtime"
"sort"
"strconv"
"strings"
Expand All @@ -37,6 +38,8 @@ import (
"golang.org/x/tools/go/types/typeutil"
)

const buildVersion = "0.5.0"

func main() {
subcommands.Register(subcommands.CommandsCommand(), "")
subcommands.Register(subcommands.FlagsCommand(), "")
Expand All @@ -45,6 +48,7 @@ func main() {
subcommands.Register(&diffCmd{}, "")
subcommands.Register(&genCmd{}, "")
subcommands.Register(&showCmd{}, "")
subcommands.Register(&versionCmd{}, "")
flag.Parse()

// Initialize the default logger to log to stderr.
Expand All @@ -64,6 +68,7 @@ func main() {
"diff": true,
"gen": true,
"show": true,
"version": true,
}
// Default to running the "gen" command.
if args := flag.Args(); len(args) == 0 || !allCmds[args[0]] {
Expand Down Expand Up @@ -607,3 +612,22 @@ func logErrors(errs []error) {
log.Println(strings.Replace(err.Error(), "\n", "\n\t", -1))
}
}

type versionCmd struct{}

func (*versionCmd) Name() string { return "version" }
func (*versionCmd) Synopsis() string {
return "print Wire version"
}
func (*versionCmd) Usage() string {
return `version

Version prints the build information for Go executables.

`
}
func (cmd *versionCmd) SetFlags(f *flag.FlagSet) {}
func (cmd *versionCmd) Execute(ctx context.Context, f *flag.FlagSet, args ...interface{}) subcommands.ExitStatus {
fmt.Printf("wire version %s %s/%s", buildVersion, runtime.GOOS, runtime.GOARCH)
return subcommands.ExitSuccess
}