summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-01-06 22:32:36 +0200
committerPaul Buetow <paul@buetow.org>2025-01-06 22:32:36 +0200
commitb9beca8449a10ba53807ecfc7d4b15cb6f14e82e (patch)
tree4fbb030ff4e7d686b642e4a0bac90362597f07d5
parent4b34876fb23e42dcc1d9414cafa367147de42ad7 (diff)
refactor colors a bit
-rw-r--r--internal/colour/colour.go32
-rw-r--r--internal/platforms/linkedin/oauth2/oauth2.go2
-rw-r--r--internal/platforms/platform.go1
-rw-r--r--internal/prompt/file.go2
-rw-r--r--internal/queue/queue.go4
5 files changed, 24 insertions, 17 deletions
diff --git a/internal/colour/colour.go b/internal/colour/colour.go
index b5f2681..5cefc58 100644
--- a/internal/colour/colour.go
+++ b/internal/colour/colour.go
@@ -7,14 +7,28 @@ import (
)
var (
- // infoCol = color.New(color.FgCyan, color.BgBlue, color.Bold)
- Infof = func(format string, args ...any) { fmt.Printf(format, args...) }
- Infoln = func(args ...any) { fmt.Println(args...) }
+ Infof = func(format string, args ...any) {
+ fmt.Printf(format, args...)
+ fmt.Print("\n")
+ }
+ Infoln = func(args ...any) { fmt.Println(args...) }
+
info2Col = color.New(color.FgHiYellow, color.BgBlue)
- Info2f = info2Col.PrintfFunc()
- SInfo2f = info2Col.SprintfFunc()
- Ackf = color.New(color.FgBlack, color.BgHiYellow, color.Bold).PrintfFunc()
- warnCol = color.New(color.FgHiWhite, color.BgRed)
- Warnf = warnCol.PrintfFunc()
- Successf = color.New(color.FgWhite, color.BgGreen).PrintfFunc()
+ Info2f = func(format string, args ...any) {
+ info2Col.Printf(format, args...)
+ fmt.Print("\n")
+ }
+ SInfo2f = info2Col.SprintfFunc()
+
+ warnCol = color.New(color.FgHiWhite, color.BgRed)
+ Warnln = warnCol.PrintlnFunc()
+
+ successCol = color.New(color.FgWhite, color.BgGreen)
+ Successf = func(format string, args ...any) {
+ successCol.Printf(format, args...)
+ fmt.Print("\n")
+
+ }
+
+ Ackf = color.New(color.FgBlack, color.BgHiYellow, color.Bold).PrintfFunc()
)
diff --git a/internal/platforms/linkedin/oauth2/oauth2.go b/internal/platforms/linkedin/oauth2/oauth2.go
index 51beec9..a07d4bc 100644
--- a/internal/platforms/linkedin/oauth2/oauth2.go
+++ b/internal/platforms/linkedin/oauth2/oauth2.go
@@ -163,10 +163,8 @@ func WaitUntilURLIsReachable(url string) error {
if err != nil {
colour.Infof("URL is not reachable: %v", err)
- fmt.Print("\n")
} else {
colour.Infof("URL is reachable: %s - Status Code: %d", url, resp.StatusCode)
- fmt.Print("\n")
resp.Body.Close()
return nil
}
diff --git a/internal/platforms/platform.go b/internal/platforms/platform.go
index f9ff84d..6d80ee2 100644
--- a/internal/platforms/platform.go
+++ b/internal/platforms/platform.go
@@ -57,7 +57,6 @@ func (p Platform) Post(ctx context.Context, args config.Args, sizeLimit int, en
}
colour.Successf("Successfully posted message to %s", p)
- fmt.Print("\n")
return nil
}
diff --git a/internal/prompt/file.go b/internal/prompt/file.go
index 2f0be02..7da24aa 100644
--- a/internal/prompt/file.go
+++ b/internal/prompt/file.go
@@ -21,9 +21,7 @@ var (
func FileAction(question, content, filePath string, includeRandomOption ...bool) (string, error) {
colour.Info2f("%s:", filePath)
- fmt.Print("\n")
colour.Info2f("%s", content)
- fmt.Print("\n")
reader := bufio.NewReader(os.Stdin)
includeRandom := len(includeRandomOption) > 0 && includeRandomOption[0] == RandomOption
diff --git a/internal/queue/queue.go b/internal/queue/queue.go
index 43a017c..cc9de9c 100644
--- a/internal/queue/queue.go
+++ b/internal/queue/queue.go
@@ -50,8 +50,7 @@ func queueEntries(args config.Args) error {
return err
}
if !hasHashtags {
- colour.Warnf("The following entry has got no hashtags:")
- fmt.Printf("\n")
+ colour.Warnln("The following entry has got no hashtags:")
}
if !hasHashtags || en.HasTag("ask") {
if err := en.FileAction("Do you want to queue this"); err != nil {
@@ -112,7 +111,6 @@ func queuePlatforms(args config.Args) error {
// Keep queued items in trash for a while.
trashPath := filepath.Join(trashDir, strings.TrimSuffix(filepath.Base(en.Path), ".queued")+".trash")
colour.Infof("Trashing %s -> %s", en.Path, trashPath)
- fmt.Print("\n")
if err := oi.EnsureParentDir(trashPath); err != nil {
return err
}