github.com/jacobsoderblom/buffalo@v0.11.0/buffalo/cmd/updater/runner.go (about) 1 package updater 2 3 import ( 4 "fmt" 5 6 "github.com/gobuffalo/buffalo/meta" 7 "github.com/pkg/errors" 8 ) 9 10 // Check interface for runnable checker functions 11 type Check func(*Runner) error 12 13 // Runner will run all compatible checks 14 type Runner struct { 15 App meta.App 16 Warnings []string 17 } 18 19 // Run all compatible checks 20 func Run() error { 21 fmt.Printf("! This updater will attempt to update your application to Buffalo version: %s\n", Version) 22 if !ask("Do you wish to continue?") { 23 fmt.Println("~~~ cancelling update ~~~") 24 return nil 25 } 26 27 r := &Runner{ 28 App: meta.New("."), 29 Warnings: []string{}, 30 } 31 32 defer func() { 33 if len(r.Warnings) == 0 { 34 return 35 } 36 37 fmt.Println("\n\n----------------------------") 38 fmt.Printf("!!! (%d) Warnings Were Found !!!\n\n", len(r.Warnings)) 39 for _, w := range r.Warnings { 40 fmt.Printf("[WARNING]: %s\n", w) 41 } 42 }() 43 44 for _, c := range checks { 45 if err := c(r); err != nil { 46 return errors.WithStack(err) 47 } 48 } 49 return nil 50 }