summaryrefslogtreecommitdiff
path: root/internal/run.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-11-22 23:25:46 +0200
committerPaul Buetow <paul@buetow.org>2024-11-22 23:25:46 +0200
commitfaf7569ab307eff706e4ccf2ed92eec5c93f67eb (patch)
treefa81064795ec6f742c5fc3eab314c83abdd2e5de /internal/run.go
parentb6f1f3f602df0368ac7ecec211e6c95b93a1c53c (diff)
implement random other
Diffstat (limited to 'internal/run.go')
-rw-r--r--internal/run.go20
1 files changed, 14 insertions, 6 deletions
diff --git a/internal/run.go b/internal/run.go
index b143cca..aeb2fc2 100644
--- a/internal/run.go
+++ b/internal/run.go
@@ -3,7 +3,7 @@ package internal
import (
"context"
"errors"
- "log"
+ "fmt"
"codeberg.org/snonux/gos/internal/colour"
"codeberg.org/snonux/gos/internal/config"
@@ -49,19 +49,27 @@ func runPlatform(ctx context.Context, args config.Args, platform platforms.Platf
case err != nil:
return err
}
+ err = postPlatform(ctx, args, platform, sizeLimit, en)
+ if errors.Is(err, prompt.ErrRamdomOther) {
+ return runPlatform(ctx, args, platform, sizeLimit)
+ }
+ return err
+}
+
+func postPlatform(ctx context.Context, args config.Args, platform platforms.Platform,
+ sizeLimit int, en entry.Entry) (err error) {
colour.Infoln("Posting", en)
- var postCB func(context.Context, config.Args, int, entry.Entry) error
switch platform.String() {
case "mastodon":
- postCB = mastodon.Post
+ err = mastodon.Post(ctx, args, sizeLimit, en)
case "linkedin":
- postCB = linkedin.Post
+ err = linkedin.Post(ctx, args, sizeLimit, en)
default:
- log.Fatal("Platform", platform, "(not yet) implemented")
+ err = fmt.Errorf("Platform '%s' (not yet) implemented", platform)
}
- if err := postCB(ctx, args, sizeLimit, en); err != nil {
+ if err != nil {
return err
}
if err := en.MarkPosted(); err != nil {