diff options
| author | Paul Buetow <paul@buetow.org> | 2025-01-03 09:58:43 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-01-03 09:58:43 +0200 |
| commit | 5cacdd83fcd28e71f798cac628b5dd602fadef50 (patch) | |
| tree | 19a53410a1c322ddceac975407f452fab890662d /internal | |
| parent | 8479058ac8f362ae646dc7f1a29eaff7308b1005 (diff) | |
warn when there is no hashtag
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/entry/entry.go | 12 | ||||
| -rw-r--r-- | internal/queue/queue.go | 11 |
2 files changed, 22 insertions, 1 deletions
diff --git a/internal/entry/entry.go b/internal/entry/entry.go index 5d3cb1b..600dbc4 100644 --- a/internal/entry/entry.go +++ b/internal/entry/entry.go @@ -164,6 +164,18 @@ func (en *Entry) MarkPosted() error { return nil } +func (en Entry) HasHashtags() (bool, error) { + content, err := oi.SlurpAndTrim(en.Path) + if err != nil { + return false, err + } + matched, err := regexp.MatchString(`#\w+`, content) + if err != nil { + return false, err + } + return matched, nil +} + func (en Entry) HasTag(tag string) bool { _, ok := en.Tags[tag] return ok diff --git a/internal/queue/queue.go b/internal/queue/queue.go index 80f6dcd..33b5bf7 100644 --- a/internal/queue/queue.go +++ b/internal/queue/queue.go @@ -44,7 +44,16 @@ func queueEntries(args config.Args) error { if err != nil { return err } - if en.HasTag("ask") { + + hasHashtags, err := en.HasHashtags() + if err != nil { + return err + } + if !hasHashtags { + if err := en.FileAction("Do you want to queue this despite there are no Hashtags?"); err != nil { + return err + } + } else if en.HasTag("ask") { if err := en.FileAction("Do you want to queue this"); err != nil { return err } |
