cli on delete todo, write in Done identified by entire struct so dupes wouldnt but thats ok

v0.2.0
Bel LaPointe 2022-03-23 09:46:16 -06:00
parent 7c84d7650c
commit 4bdee5d9a0
3 changed files with 22 additions and 3 deletions

View File

@ -167,7 +167,18 @@ func edit(dry bool, filepaths []string) error {
return err
}
original := originals[target]
newTodoIDs := map[string]struct{}{}
for i := range newTodos {
newTodoIDs[newTodos[i].ID()] = struct{}{}
}
for i := range original.Todo {
if _, ok := newTodoIDs[original.Todo[i].ID()]; !ok {
original.Done = append(original.Done, original.Todo[i])
}
}
original.Todo = newTodos
original.AutoMove()
c, err := yaml.Marshal(original)
if err != nil {

Binary file not shown.

View File

@ -1,7 +1,5 @@
todo:
- a
- b
- a
scheduled:
- todo: abc
schedule: "2022-05-01"
@ -9,4 +7,14 @@ scheduled:
- todo: def
schedule: "2022-05-01"
ts: Wed Mar 23 08:04:05 MDT 2022
done: []
done:
- todo: other
ts: Wed Mar 23 09:44:57 MDT 2022
- todo: b
ts: Wed Mar 23 09:45:13 MDT 2022
- todo: a
ts: Wed Mar 23 09:45:15 MDT 2022
- todo: a
ts: Wed Mar 23 09:45:24 MDT 2022
- todo: a
ts: Wed Mar 23 09:45:31 MDT 2022