diff options
| author | Paul Buetow <paul@buetow.org> | 2024-10-27 17:19:34 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2024-10-27 17:19:34 +0200 |
| commit | 3d8935e6456bcfe462bd7735615e9009ef5ff7c6 (patch) | |
| tree | 342ba25a782d72490b9fa5931685e818a79a2aaf /internal/queue/queue.go | |
| parent | e17fa34a36835930a0ec1678e086f450cb9aa620 (diff) | |
can ask before queueing
Diffstat (limited to 'internal/queue/queue.go')
| -rw-r--r-- | internal/queue/queue.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/queue/queue.go b/internal/queue/queue.go index 2f8c780..e396761 100644 --- a/internal/queue/queue.go +++ b/internal/queue/queue.go @@ -1,6 +1,7 @@ package queue import ( + "errors" "fmt" "log" "os" @@ -11,6 +12,7 @@ import ( "codeberg.org/snonux/gos/internal/config" "codeberg.org/snonux/gos/internal/oi" + "codeberg.org/snonux/gos/internal/prompt" "codeberg.org/snonux/gos/internal/timestamp" ) @@ -40,6 +42,25 @@ func queueEntries(args config.Args) error { } for filePath := range ch { + if strings.Contains(filepath.Base(filePath), ".ask.") { + bytes, err := os.ReadFile(filePath) + if err != nil { + return err + } + // TODO Refactor + err = prompt.DoYouWantThis("Do you want to queue this content", strings.TrimSpace(string(bytes))) + switch { + case errors.Is(err, prompt.ErrEditContent): + err = prompt.EditFile(filePath) + case errors.Is(err, prompt.ErrDeleteFile): + if err = os.Remove(filePath); err == nil { + continue + } + } + if err != nil { + return err + } + } destPath := fmt.Sprintf("%s/db/%s.%s.queued", args.GosDir, filepath.Base(filePath), timestamp.Now()) if args.DryRun { |
