bucket inboxes by target for excessive automoving
parent
ba81940b0b
commit
9b482d45b4
24
cmd/edit.go
24
cmd/edit.go
|
|
@ -12,8 +12,8 @@ import (
|
|||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"gitea.inhome.blapointe.com/gogs/pttodo/pttodo"
|
||||
"github.com/google/uuid"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
|
|
@ -135,11 +135,12 @@ func inEditableDirAsTodos(filepaths []string) (string, error) {
|
|||
}
|
||||
|
||||
func copyTodoToDir(d string, filepaths []string) error {
|
||||
inboxes := []string{}
|
||||
inboxes := map[string][]string{}
|
||||
for _, target := range filepaths {
|
||||
p := path.Join(d, path.Base(target))
|
||||
if strings.Contains(path.Base(target), ".todo.") {
|
||||
inboxes = append(inboxes, target)
|
||||
p := path.Join(d, strings.Split(path.Base(p), ".todo")[0])
|
||||
inboxes[p] = append(inboxes[p], target)
|
||||
continue
|
||||
}
|
||||
if root, err := pttodo.NewRootFromFile(target); err != nil {
|
||||
|
|
@ -150,18 +151,21 @@ func copyTodoToDir(d string, filepaths []string) error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
for _, inbox := range inboxes {
|
||||
target := path.Join(path.Dir(inbox), strings.Split(path.Base(inbox), ".todo.")[0])
|
||||
p := path.Join(d, path.Base(target))
|
||||
for p, inboxes := range inboxes {
|
||||
inboxRoot := pttodo.Root{}
|
||||
for _, inbox := range inboxes {
|
||||
subInboxRoot, err := pttodo.NewRootFromFile(inbox)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
inboxRoot.MergeIn(pttodo.Root{Todo: subInboxRoot.Todo})
|
||||
inboxRoot.MergeIn(pttodo.Root{Todo: subInboxRoot.Scheduled})
|
||||
}
|
||||
|
||||
root, err := pttodo.NewRootFromFile(p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
inboxRoot, err := pttodo.NewRootFromFile(inbox)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
root.MergeIn(pttodo.Root{Todo: inboxRoot.Todo})
|
||||
root.MergeIn(pttodo.Root{Todo: inboxRoot.Scheduled})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue