summaryrefslogtreecommitdiff
path: root/internal/task
diff options
context:
space:
mode:
authorPaul Bütow <1224732+snonux@users.noreply.github.com>2025-06-20 18:42:43 +0300
committerPaul Bütow <1224732+snonux@users.noreply.github.com>2025-06-20 18:42:43 +0300
commitbf30a97b8abefd550d795479af1781a53ad635c6 (patch)
tree7f6e064c61d9164da21dec02113468650c154347 /internal/task
parentfd6ac6bf1c2269093ba9fa0b20365a31d12a7bfa (diff)
Add A hotkey to replace annotations
Diffstat (limited to 'internal/task')
-rw-r--r--internal/task/task.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/internal/task/task.go b/internal/task/task.go
index 9b59cfb..f328838 100644
--- a/internal/task/task.go
+++ b/internal/task/task.go
@@ -175,6 +175,29 @@ func Denotate(id int, annoID int) error {
return run(strconv.Itoa(id), "denotate", strconv.Itoa(annoID))
}
+// ReplaceAnnotations removes all existing annotations from the task with the
+// given id and sets a single annotation with the provided text. If text is
+// empty, all annotations are simply removed.
+func ReplaceAnnotations(id int, text string) error {
+ tasks, err := Export(strconv.Itoa(id))
+ if err != nil {
+ return err
+ }
+ if len(tasks) == 0 {
+ return fmt.Errorf("task %d not found", id)
+ }
+ anns := tasks[0].Annotations
+ for i := len(anns); i >= 1; i-- {
+ if err := Denotate(id, i); err != nil {
+ return err
+ }
+ }
+ if text == "" {
+ return nil
+ }
+ return Annotate(id, text)
+}
+
// Edit opens the task in an editor for manual modification.
// EditCmd returns an exec.Cmd that edits the task with the given id.
// The caller is responsible for running the command, typically via