Files
forego/update.go
T
2013-09-18 12:22:59 -04:00

45 lines
752 B
Go

package main
import (
"bitbucket.org/kardianos/osext"
"fmt"
"github.com/ddollar/dist"
)
var cmdUpdate = &Command{
Run: runUpdate,
Usage: "update [version]",
Short: "Update forego",
Long: `
Update forego
Examples:
forego update
forego update 0.3.0
`,
}
func init() {
}
func runUpdate(cmd *Command, args []string) {
binary, _ := osext.Executable()
d := dist.NewDist(binary, "https://godist.herokuapp.com", "ddollar/forego")
if len(args) > 0 {
err := d.UpdateTo(args[0])
if err != nil {
fmt.Printf("ERROR: %s\n", err)
} else {
fmt.Printf("updated to %s\n", args[0])
}
} else {
version, err := d.Update()
if err != nil {
fmt.Printf("ERROR: %s\n", err)
} else {
fmt.Printf("updated to %s\n", version)
}
}
}