blob: 66ccfb3c58437b77fc600dec0226bc1eb0e6e34d (
plain)
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
48
49
50
51
|
package commands
import (
"fmt"
"github.com/Fuwn/yae/internal/yae"
"github.com/urfave/cli/v2"
)
func Update(sources *yae.Sources) func(c *cli.Context) error {
return func(c *cli.Context) error {
updates := []string{}
force := c.Bool("force-hashed")
forcePinned := c.Bool("force-pinned")
if c.Args().Len() == 0 {
for name, source := range *sources {
if updated, err := source.Update(sources, name, force, forcePinned); err != nil {
return err
} else if updated {
updates = append(updates, name)
}
}
} else {
name := c.Args().Get(0)
source := (*sources)[name]
if updated, err := source.Update(sources, name, force, forcePinned); err != nil {
return err
} else if updated {
updates = append(updates, name)
}
}
if len(updates) > 0 {
if err := sources.Save(c.String("sources")); err != nil {
return err
}
}
if c.Bool("output-updated-list") {
for _, update := range updates {
fmt.Println(update)
}
} else if c.Bool("output-formatted-updated-list") {
fmt.Println(yae.Lister(updates))
}
return nil
}
}
|