summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)
+ },
+ },
},
}