summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordemo <demo@antix1>2026-05-29 11:56:19 -0400
committerdemo <demo@antix1>2026-05-29 11:56:19 -0400
commitd0e25d1cb7abce926bf8e5f1f6862e448907bdda (patch)
tree05c4e05205d0178087277edc77ca386313735fac
parent32f2ce19cc5e96cf34c8be1da9308412a4010383 (diff)
feat: add 'rm INDEX' command
-rw-r--r--cmds.go7
-rw-r--r--main.go18
2 files changed, 25 insertions, 0 deletions
diff --git a/cmds.go b/cmds.go
index 38be692..a0c2334 100644
--- a/cmds.go
+++ b/cmds.go
@@ -96,3 +96,10 @@ func (ctrl controller) cmdList() error {
return nil
})
}
+
+func (ctrl controller) cmdRm(taskIndex int) error {
+ return ctrl.db.Update(func(tx *bbolt.Tx) error {
+ taskBucket := tx.Bucket(ctrl.tasksBucketName)
+ return taskBucket.Delete(itob(uint64(taskIndex)))
+ })
+}
diff --git a/main.go b/main.go
index 7838fcb..81d916a 100644
--- a/main.go
+++ b/main.go
@@ -108,6 +108,24 @@ func main() {
return ctrl.cmdList()
},
},
+ {
+ Name: "rm",
+ Usage: "delete a task permanently",
+ Arguments: []cli.Argument{
+ &cli.IntArg{
+ Name: "taskIndex",
+ },
+ },
+ Action: func(ctx context.Context, cmd *cli.Command) error {
+ taskIndex := cmd.IntArg("taskIndex")
+
+ if taskIndex <= 0 {
+ return fmt.Errorf("invalid 'undo' argument: %d", taskIndex)
+ }
+
+ return ctrl.cmdRm(taskIndex)
+ },
+ },
},
}