diff options
| author | Fuwn <[email protected]> | 2024-10-12 14:01:15 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-10-12 14:01:15 +0000 |
| commit | 693a1e8a41903a739c227bfe489f8912111a4674 (patch) | |
| tree | 9b955f57a43f847bfee34e7a83e14d61852d2878 | |
| parent | feat(source): extra output logs (diff) | |
| download | yae-693a1e8a41903a739c227bfe489f8912111a4674.tar.xz yae-693a1e8a41903a739c227bfe489f8912111a4674.zip | |
refactor(yae): control logging through silent flag
| -rw-r--r-- | source.go | 24 | ||||
| -rw-r--r-- | yae.go | 5 |
2 files changed, 9 insertions, 20 deletions
@@ -20,25 +20,19 @@ type Source struct { Force bool `json:"force,omitempty"` } -func (source *Source) Update(sources *Sources, name string, show bool, force bool, forcePinned bool) (bool, error) { - if show { - log.Infof("checking %s", name) - } +func (source *Source) Update(sources *Sources, name string, force bool, forcePinned bool) (bool, error) { + log.Infof("checking %s", name) updated := false if !sources.Exists(name) { - if show { - log.Warnf("skipped %s: source does not exist", name) - } + log.Warnf("skipped %s: source does not exist", name) return updated, nil } if source.Pinned && !forcePinned { - if show { - log.Infof("skipped %s: source is pinned", name) - } + log.Infof("skipped %s: source is pinned", name) return updated, nil } @@ -53,7 +47,7 @@ func (source *Source) Update(sources *Sources, name string, show bool, force boo } if tag != source.Version || force || source.Force { - if show && tag != source.Version { + if tag != source.Version { log.Infof("bumped %s: %s -> %s", name, source.Version, tag) } @@ -67,9 +61,7 @@ func (source *Source) Update(sources *Sources, name string, show bool, force boo source.URL = strings.ReplaceAll(source.URLTemplate, "{version}", source.Version) } } else { - if show { - log.Infof("skipped %s: version remains unchanged", name) - } + log.Infof("skipped %s: version remains unchanged", name) return updated, nil } @@ -82,9 +74,7 @@ func (source *Source) Update(sources *Sources, name string, show bool, force boo } if sha256 != source.SHA256 { - if show { - log.Infof("rehashed %s: %s -> %s", name, source.SHA256, sha256) - } + log.Infof("rehashed %s: %s -> %s", name, source.SHA256, sha256) source.SHA256 = sha256 updated = true @@ -220,14 +220,13 @@ func main() { }, }, Action: func(c *cli.Context) error { - showAll := !c.Bool("show-updated-only") && !c.Bool("show-updated-only-formatted") 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, showAll, force, forcePinned); err != nil { + if updated, err := source.Update(&sources, name, force, forcePinned); err != nil { return err } else if updated { updates = append(updates, name) @@ -237,7 +236,7 @@ func main() { name := c.Args().Get(0) source := sources[name] - if updated, err := source.Update(&sources, name, showAll, force, forcePinned); err != nil { + if updated, err := source.Update(&sources, name, force, forcePinned); err != nil { return err } else if updated { updates = append(updates, name) |