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