aboutsummaryrefslogtreecommitdiff
path: root/yae.go
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-10-11 03:51:51 -0700
committerFuwn <[email protected]>2024-10-11 03:51:51 -0700
commitfe2456feedea9fffbe6ebf5fc668cd99464301a4 (patch)
treeac94602eae6ca3063b3bb3de654c4bcf3ed8f2bb /yae.go
parentf8622a0f8c21bd9842b6a48c2ac1d5b33bc75016 (diff)
downloadyae-fe2456feedea9fffbe6ebf5fc668cd99464301a4.tar.xz
yae-fe2456feedea9fffbe6ebf5fc668cd99464301a4.zip
feat(yae): add listed output for update
Diffstat (limited to 'yae.go')
-rw-r--r--yae.go22
1 files changed, 20 insertions, 2 deletions
diff --git a/yae.go b/yae.go
index 613ae2a..d7be200 100644
--- a/yae.go
+++ b/yae.go
@@ -165,9 +165,13 @@ func main() {
Name: "show-updated-only",
Usage: "Output a newline-seperated list of updated sources, silence other output",
},
+ &cli.BoolFlag{
+ Name: "show-updated-only-formatted",
+ Usage: "Output a comma and/or ampersand list of updated sources, silence other output",
+ },
},
Action: func(c *cli.Context) error {
- showAll := !c.Bool("show-updated-only")
+ showAll := !c.Bool("show-updated-only") && !c.Bool("show-updated-only-formatted")
updates := []string{}
if c.Args().Len() == 0 {
@@ -192,10 +196,12 @@ func main() {
return err
}
- if !showAll {
+ if c.Bool("show-updated-only") {
for _, update := range updates {
fmt.Println(update)
}
+ } else if c.Bool("show-updated-only-formatted") {
+ fmt.Println(lister(updates))
}
return nil
@@ -320,3 +326,15 @@ func updateSource(sources *Sources, name string, source Source, show bool) (bool
return updated, nil
}
+
+func lister(items []string) string {
+ if len(items) == 0 {
+ return ""
+ } else if len(items) == 1 {
+ return items[0]
+ } else if len(items) == 2 {
+ return fmt.Sprintf("%s & %s", items[0], items[1])
+ }
+
+ return fmt.Sprintf("%s, & %s", strings.Join(items[:len(items)-1], ", "), items[len(items)-1])
+}