Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

report wire build version #298

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
}