From dc4aeba03243106f00c12aca7799e2a79f66a01e Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sat, 12 Oct 2024 12:11:53 +0000 Subject: refactor(utilities): move lister to utilities --- source.go | 12 ------------ utilities.go | 13 +++++++++++++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/source.go b/source.go index 4665ce3..d1e5f4a 100644 --- a/source.go +++ b/source.go @@ -116,15 +116,3 @@ func fetchLatestGitTag(source Source, show bool) (string, error) { return "", fmt.Errorf("source is not a git repository") } - -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]) -} diff --git a/utilities.go b/utilities.go index b5c540f..7548da4 100644 --- a/utilities.go +++ b/utilities.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "os" "os/exec" "strings" @@ -40,3 +41,15 @@ func command(name string, show bool, args ...string) (string, error) { return string(out), err } + +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]) +} -- cgit v1.2.3