github.com/mhlo/force@v0.22.28-0.20150915022417-6d05ecfb0b47/update.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "github.com/ddollar/dist" 6 ) 7 8 var cmdUpdate = &Command{ 9 Run: runUpdate, 10 Usage: "update", 11 Short: "Update to the latest version", 12 Long: ` 13 Update to the latest version 14 15 Examples: 16 17 force update 18 `, 19 } 20 21 func init() { 22 } 23 24 func runUpdate(cmd *Command, args []string) { 25 d := dist.NewDist("heroku/force", Version) 26 if len(args) == 1 { 27 err := d.FullUpdate(args[0]) 28 if err != nil { 29 ErrorAndExit(err.Error()) 30 } else { 31 fmt.Printf("updated to %s\n", args[0]) 32 } 33 } else { 34 if Version == "dev" { 35 ErrorAndExit("can't update dev version") 36 } 37 to, err := d.Update() 38 if err != nil { 39 ErrorAndExit(err.Error()) 40 } else { 41 fmt.Printf("updated to %s\n", to) 42 } 43 } 44 }