forked from fishworks/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upgrade.go
41 lines (38 loc) · 929 Bytes
/
upgrade.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
package main
import (
"time"
"github.com/fishworks/gofish/pkg/ohai"
"github.com/spf13/cobra"
)
func newUpgradeCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "upgrade [food..]",
Short: "upgrade all fish food. If arguments are provided, only the specified fish foods are upgraded.",
RunE: func(cmd *cobra.Command, args []string) error {
if err := updateRigs(); err != nil {
return err
}
var foodNames []string
if len(args) > 0 {
foodNames = args
} else {
foodNames = findFood()
}
for _, name := range foodNames {
food, _, err := getFood(name)
if err != nil {
return err
}
ohai.Ohaif("Upgrading %s...\n", food.Name)
start := time.Now()
if err := food.Install(); err != nil {
return err
}
t := time.Now()
ohai.Successf("%s %s: upgraded in %s\n", food.Name, food.Version, t.Sub(start).String())
}
return nil
},
}
return cmd
}