summaryrefslogtreecommitdiff
path: root/cmds.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmds.go')
-rw-r--r--cmds.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/cmds.go b/cmds.go
index 5791546..38be692 100644
--- a/cmds.go
+++ b/cmds.go
@@ -43,7 +43,7 @@ func (ctrl controller) cmdAdd(task string) error {
})
}
-func (ctrl controller) cmdDo(taskIndex int) error {
+func (ctrl controller) toggleDo(taskIndex int, status bool) error {
return ctrl.db.Update(func(tx *bbolt.Tx) error {
taskBucket := tx.Bucket(ctrl.tasksBucketName)
ttBytes := taskBucket.Get(itob(uint64(taskIndex)))
@@ -53,7 +53,7 @@ func (ctrl controller) cmdDo(taskIndex int) error {
return fmt.Errorf("can't unmarshal: %w", err)
}
- tt.Done = true
+ tt.Done = status
buf, err := json.Marshal(tt)
if err != nil {
@@ -64,6 +64,14 @@ func (ctrl controller) cmdDo(taskIndex int) error {
})
}
+func (ctrl controller) cmdDo(taskIndex int) error {
+ return ctrl.toggleDo(taskIndex, true)
+}
+
+func (ctrl controller) cmdUndo(taskIndex int) error {
+ return ctrl.toggleDo(taskIndex, false)
+}
+
func (ctrl controller) cmdList() error {
return ctrl.db.View(func(tx *bbolt.Tx) error {
// Assume bucket exists and has keys