summaryrefslogtreecommitdiff
path: root/internal/run.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-02-26 15:24:33 +0200
committerPaul Buetow <paul@buetow.org>2025-02-26 15:24:33 +0200
commit547afd8c0921a7de16f0a5ce8b5d8d09bb2268c8 (patch)
tree8490aee787d4c6f9b3e025b67d888a5367def91e /internal/run.go
parente735b56a704b7328e7e84def46fd6d248c51e38d (diff)
introduce run interval
Diffstat (limited to 'internal/run.go')
-rw-r--r--internal/run.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/internal/run.go b/internal/run.go
index ac3f75e..27d6aeb 100644
--- a/internal/run.go
+++ b/internal/run.go
@@ -19,9 +19,10 @@ func run(ctx context.Context, args config.Args) error {
if len(args.GeminiSummaryFor) > 0 {
return summary.Run(ctx, args)
}
+ now := time.Now().Unix()
if args.ComposeMode {
- entryPath := fmt.Sprintf("%s/%d.ask.txt", args.GosDir, time.Now().Unix())
+ entryPath := fmt.Sprintf("%s/%d.ask.txt", args.GosDir, now)
if err := prompt.EditFile(entryPath); err != nil {
return err
}
@@ -34,6 +35,12 @@ func run(ctx context.Context, args config.Args) error {
colour.Infoln(err)
}
+ sinceLastRun := time.Duration(now-args.Config.LastRunEpoch) * time.Second
+ if sinceLastRun < args.RunInterval {
+ colour.Infoln("Run interval", args.RunInterval, "with", sinceLastRun, "not yet reached. Not posting anything!")
+ return nil
+ }
+
for platformStr, sizeLimit := range args.Platforms {
platform, err := platforms.New(platformStr)
if err != nil {
@@ -48,7 +55,8 @@ func run(ctx context.Context, args config.Args) error {
}
}
- return nil
+ args.Config.LastRunEpoch = now
+ return args.Config.WriteToDisk(args.ConfigPath)
}
func runPlatform(ctx context.Context, args config.Args, platform platforms.Platform, sizeLimit int) error {