diff --git a/Changelog.md b/Changelog.md index 84c7c3e..5fa1cff 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,7 @@ +# v28 2015/11/09 + +* Make `version` an actual command. + # v27 2015/11/06 * run command once during restore -v diff --git a/main.go b/main.go index bc83b04..ab7fabc 100644 --- a/main.go +++ b/main.go @@ -6,7 +6,6 @@ import ( "io" "log" "os" - "runtime" "strings" "text/template" ) @@ -63,6 +62,7 @@ var commands = []*Command{ cmdRestore, cmdUpdate, cmdDiff, + cmdVersion, } func main() { @@ -80,11 +80,6 @@ func main() { return } - if args[0] == "version" { - fmt.Printf("godep v%d (%s/%s/%s)\n", version, runtime.GOOS, runtime.GOARCH, runtime.Version()) - return - } - for _, cmd := range commands { if cmd.Name() == args[0] { cmd.Flag.Usage = func() { cmd.UsageExit() } diff --git a/version.go b/version.go index 513b7f2..c742b26 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,22 @@ package main -const version = 27 +import ( + "fmt" + "runtime" +) + +const version = 28 + +var cmdVersion = &Command{ + Usage: "version", + Short: "show version info", + Long: ` + +Displays the version of godep as well as the target OS, architecture and go runtime version. +`, + Run: runVersion, +} + +func runVersion(cmd *Command, args []string) { + fmt.Printf("godep v%d (%s/%s/%s)\n", version, runtime.GOOS, runtime.GOARCH, runtime.Version()) +}