aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-10-12 14:01:15 +0000
committerFuwn <[email protected]>2024-10-12 14:01:15 +0000
commit693a1e8a41903a739c227bfe489f8912111a4674 (patch)
tree9b955f57a43f847bfee34e7a83e14d61852d2878
parentfeat(source): extra output logs (diff)
downloadyae-693a1e8a41903a739c227bfe489f8912111a4674.tar.xz
yae-693a1e8a41903a739c227bfe489f8912111a4674.zip
refactor(yae): control logging through silent flag
-rw-r--r--source.go24
-rw-r--r--yae.go5
2 files changed, 9 insertions, 20 deletions
diff --git a/source.go b/source.go
index b62489d..93b5157 100644
--- a/source.go
+++ b/source.go
@@ -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
diff --git a/yae.go b/yae.go
index 9d05dd0..ea11354 100644
--- a/yae.go
+++ b/yae.go
@@ -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)