summaryrefslogtreecommitdiff
path: root/internal/task/task.go
diff options
context:
space:
mode:
authorPaul Bütow <1224732+snonux@users.noreply.github.com>2025-06-20 18:43:18 +0300
committerGitHub <noreply@github.com>2025-06-20 18:43:18 +0300
commita9e322ff7e83364868dc56fd9ac1d8acbc5ce08b (patch)
treef854d7a853229e13728368985bdba463b379d0c0 /internal/task/task.go
parent6acfce72b3ed9d814e546dc35ebfb45c8f833f41 (diff)
parentbf30a97b8abefd550d795479af1781a53ad635c6 (diff)
Merge pull request #26 from snonux/codex/add-a-hotkey-for-annotations-and-help
Add annotation replacement hotkey
Diffstat (limited to 'internal/task/task.go')
-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