Compare commits
154 Commits
v0.1.0
...
6eba05895f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6eba05895f | ||
|
|
5a45cd1410 | ||
|
|
7832d09fe8 | ||
|
|
aa9e032c31 | ||
|
|
b949502869 | ||
|
|
41cab74028 | ||
|
|
e389f34bd6 | ||
|
|
3cfaf1f1a0 | ||
|
|
b1d1c5d2b2 | ||
|
|
4d8fd0597b | ||
|
|
8f8202282f | ||
|
|
e81f221910 | ||
|
|
7ad6dad214 | ||
|
|
c7163268d4 | ||
|
|
e90cf02664 | ||
|
|
7129723442 | ||
|
|
74b02118bc | ||
|
|
c7b0fc8dba | ||
|
|
50e9c80473 | ||
|
|
c5ed06b76c | ||
|
|
039c4dad04 | ||
|
|
3c132528e3 | ||
|
|
1639286189 | ||
|
|
2a04a030f7 | ||
|
|
931edec4a4 | ||
|
|
4154e1aad8 | ||
|
|
4f4e7fd907 | ||
|
|
a627223e8a | ||
|
|
00813e39a9 | ||
|
|
66f533a210 | ||
|
|
233967e177 | ||
|
|
282f653c75 | ||
|
|
1d958e8a52 | ||
|
|
5a75b3e5f2 | ||
|
|
ad9c32c987 | ||
|
|
3ee1dc069e | ||
|
|
9b482d45b4 | ||
|
|
ba81940b0b | ||
|
|
5d74b458d5 | ||
|
|
f3ac2c63fe | ||
|
|
a3ca9b1917 | ||
|
|
ca84bcbee3 | ||
|
|
89a8f61fa3 | ||
|
|
d3f34709b3 | ||
|
|
ea904ea729 | ||
|
|
ead31e077b | ||
|
|
36c5228a6c | ||
|
|
72fee73a00 | ||
|
|
550bace88d | ||
|
|
0329b9690c | ||
|
|
fe8595cc68 | ||
|
|
3549010ab4 | ||
|
|
caa9f9d6fd | ||
|
|
8b63254cf0 | ||
|
|
97f2cb197f | ||
|
|
b2a51e65b0 | ||
|
|
f75dcb3f7a | ||
|
|
d4466598b4 | ||
|
|
3ba3b78afc | ||
|
|
f2e3e6f505 | ||
|
|
1ce120a647 | ||
|
|
bfdeebb7a2 | ||
|
|
39345e5e2a | ||
|
|
bfcec9d1c5 | ||
|
|
3e1f58c7b9 | ||
|
|
92e8e14c08 | ||
|
|
84aa7cb319 | ||
|
|
d36f9e74b3 | ||
|
|
8dacd8da5d | ||
|
|
23ef7f13ee | ||
|
|
02dab4b726 | ||
|
|
cdd1be46a8 | ||
|
|
760c822323 | ||
|
|
4e69646e88 | ||
|
|
9aee322c4e | ||
|
|
887875f6d8 | ||
|
|
d2f986d8b6 | ||
|
|
58aa05c155 | ||
|
|
97aff0f0b8 | ||
|
|
eb20706d12 | ||
|
|
a800227c6f | ||
|
|
2c7563c1ab | ||
|
|
a8a135bb2f | ||
|
|
c1c625afc0 | ||
|
|
0b790e3468 | ||
|
|
7175d777cb | ||
|
|
debe28dbbc | ||
|
|
c1426566a0 | ||
|
|
6f79f7da5e | ||
|
|
284d7c06bd | ||
|
|
be702b1d74 | ||
|
|
de62d99340 | ||
|
|
bca9259caa | ||
|
|
dccf5c4028 | ||
|
|
55e174e3b1 | ||
|
|
d7dab75f48 | ||
|
|
3426deae4d | ||
|
|
7fe4686c05 | ||
|
|
eb57593665 | ||
|
|
814ae3ab23 | ||
|
|
939793bd3f | ||
|
|
1d26cf125f | ||
|
|
e20ce478d5 | ||
|
|
0bd6347a93 | ||
|
|
20770ff5e6 | ||
|
|
65178b8bdf | ||
|
|
4066d4aeb5 | ||
|
|
7f611e67bc | ||
|
|
71c03f3ef5 | ||
|
|
4b8d82c2a0 | ||
|
|
850ff92d98 | ||
|
|
c2d1381607 | ||
|
|
33ca7c60e1 | ||
|
|
cde6ea6cb6 | ||
|
|
6d3f423845 | ||
|
|
fe1bd22987 | ||
|
|
6f9589b100 | ||
|
|
a0c0cb7053 | ||
|
|
4a22b964db | ||
|
|
2caf2ae352 | ||
|
|
455a7d52d5 | ||
|
|
1a9221f7c7 | ||
|
|
6178e6ff93 | ||
|
|
fdb24fcc60 | ||
|
|
8002b5e75c | ||
|
|
3dd8cd1e03 | ||
|
|
c6ab36806d | ||
|
|
bf997c1814 | ||
|
|
69eb868db6 | ||
|
|
0c80162394 | ||
|
|
c634fdd4d4 | ||
|
|
92d76443bc | ||
|
|
a51d5e6960 | ||
|
|
7fc594d5c2 | ||
|
|
2d8cfa6397 | ||
|
|
f01dc04277 | ||
|
|
249ee84688 | ||
|
|
4111d1f490 | ||
|
|
5b6f62983b | ||
|
|
1056f5d29e | ||
|
|
7886723fe3 | ||
|
|
ff77af9ed4 | ||
|
|
3bd1c6462d | ||
|
|
3bcabde553 | ||
|
|
604cd610a1 | ||
|
|
9d35347b0c | ||
|
|
1a8c687260 | ||
|
|
3246900db0 | ||
|
|
79cc171af5 | ||
|
|
a75d898487 | ||
|
|
f63f152b0e | ||
|
|
76a0231511 | ||
|
|
7f37feea77 | ||
|
|
b84f8b59c9 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -3,3 +3,6 @@ todo-server-yaml
|
|||||||
cmd/cmd
|
cmd/cmd
|
||||||
cmd/cli
|
cmd/cli
|
||||||
cmd/pttodo/pttodo
|
cmd/pttodo/pttodo
|
||||||
|
cmd/pttodo-cli/pttodo-cli
|
||||||
|
cmd/pttodo-cli
|
||||||
|
pttodoer/target
|
||||||
|
|||||||
36
cmd/add.go
Normal file
36
cmd/add.go
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"gitea.inhome.blapointe.com/gogs/pttodo/pttodo"
|
||||||
|
"gopkg.in/yaml.v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
func add(config *config) error {
|
||||||
|
if config.add == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
v := pttodo.Todo{
|
||||||
|
Todo: config.add,
|
||||||
|
Schedule: pttodo.Schedule(config.addSchedule),
|
||||||
|
Tags: config.addTags,
|
||||||
|
}
|
||||||
|
return _add(config.Targets()[0], v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _add(filepath string, todo pttodo.Todo) error {
|
||||||
|
target := fmt.Sprintf("%s.todo.%s", filepath, uuid.New().String())
|
||||||
|
|
||||||
|
c, err := yaml.Marshal([]pttodo.Todo{todo})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else if err := ioutil.WriteFile(target, c, os.ModePerm); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
98
cmd/config.go
Normal file
98
cmd/config.go
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type config struct {
|
||||||
|
target string
|
||||||
|
root string
|
||||||
|
tags []string
|
||||||
|
search string
|
||||||
|
edit bool
|
||||||
|
add string
|
||||||
|
addSchedule string
|
||||||
|
addTags string
|
||||||
|
}
|
||||||
|
|
||||||
|
func getConfig() config {
|
||||||
|
defaultFilepath := os.Getenv("PTTODO_FILE")
|
||||||
|
if defaultFilepath == "" {
|
||||||
|
defaultFilepath = "./todo.yaml"
|
||||||
|
}
|
||||||
|
|
||||||
|
var config config
|
||||||
|
flag.StringVar(&config.target, "f", defaultFilepath, "($PTTODO_FILE) path to yaml file or dir (starting with root then alphabetical for dir)")
|
||||||
|
flag.StringVar(&config.root, "root", DUMP_TODO, "path to pretty print ("+fmt.Sprint([]string{DUMP_ALL, DUMP_TODO, DUMP_SCHEDULED, DUMP_DONE})+")")
|
||||||
|
var tagss string
|
||||||
|
flag.StringVar(&tagss, "tags", "", "csv of all tags to find, -x to invert")
|
||||||
|
flag.StringVar(&config.search, "search", "", "fts case insensitive")
|
||||||
|
flag.BoolVar(&config.edit, "e", false, "edit file")
|
||||||
|
flag.StringVar(&config.add, "add", "", "todo to add")
|
||||||
|
flag.StringVar(&config.addSchedule, "add-schedule", "", "todo to add schedule")
|
||||||
|
flag.StringVar(&config.addTags, "add-tags", "", "todo to add csv tags")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
config.tags = strings.Split(tagss, ",")
|
||||||
|
|
||||||
|
config.Targets()
|
||||||
|
|
||||||
|
return config
|
||||||
|
}
|
||||||
|
|
||||||
|
func (config config) Targets() []string {
|
||||||
|
result, err := config.targets()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
sort.Strings(result)
|
||||||
|
for i := range result {
|
||||||
|
if path.Base(result[i]) == "root.yaml" {
|
||||||
|
newresult := append([]string{result[i]}, result[:i]...)
|
||||||
|
newresult = append(newresult, result[i+1:]...)
|
||||||
|
result = newresult
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func (config config) targets() ([]string, error) {
|
||||||
|
patterns := []string{config.target, fmt.Sprintf("%s.*", config.target)}
|
||||||
|
isDir := false
|
||||||
|
if stat, err := os.Stat(config.target); err == nil {
|
||||||
|
isDir = stat.IsDir()
|
||||||
|
}
|
||||||
|
if isDir {
|
||||||
|
patterns = []string{fmt.Sprintf("%s/*", config.target)}
|
||||||
|
}
|
||||||
|
|
||||||
|
result := make([]string, 0, 1)
|
||||||
|
for _, pattern := range patterns {
|
||||||
|
results, err := filepath.Glob(pattern)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for i := range results {
|
||||||
|
if stat, err := os.Stat(results[i]); err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else if !stat.IsDir() {
|
||||||
|
result = append(result, results[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(result) == 0 {
|
||||||
|
if isDir {
|
||||||
|
return []string{path.Join(config.target, "root.yaml")}, nil
|
||||||
|
}
|
||||||
|
return []string{config.target}, nil
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
87
cmd/config_test.go
Normal file
87
cmd/config_test.go
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestConfigTargets(t *testing.T) {
|
||||||
|
touch := func(t *testing.T, p string) {
|
||||||
|
if err := os.WriteFile(p, nil, os.ModePerm); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cases := map[string]struct {
|
||||||
|
setup func(*testing.T, string)
|
||||||
|
given string
|
||||||
|
want []string
|
||||||
|
}{
|
||||||
|
"does not exist": {
|
||||||
|
given: "x",
|
||||||
|
want: []string{"x"},
|
||||||
|
},
|
||||||
|
"one file": {
|
||||||
|
setup: func(t *testing.T, d string) {
|
||||||
|
touch(t, path.Join(d, "x"))
|
||||||
|
},
|
||||||
|
given: "x",
|
||||||
|
want: []string{"x"},
|
||||||
|
},
|
||||||
|
"two files": {
|
||||||
|
setup: func(t *testing.T, d string) {
|
||||||
|
touch(t, path.Join(d, "a"))
|
||||||
|
touch(t, path.Join(d, "root.yaml"))
|
||||||
|
touch(t, path.Join(d, "z"))
|
||||||
|
},
|
||||||
|
given: "",
|
||||||
|
want: []string{"root.yaml", "a", "z"},
|
||||||
|
},
|
||||||
|
"empty dir": {
|
||||||
|
setup: func(t *testing.T, d string) {
|
||||||
|
os.Mkdir(path.Join(d, "x"), os.ModePerm)
|
||||||
|
},
|
||||||
|
given: "x",
|
||||||
|
want: []string{"root.yaml"},
|
||||||
|
},
|
||||||
|
"dir": {
|
||||||
|
setup: func(t *testing.T, d string) {
|
||||||
|
os.Mkdir(path.Join(d, "x"), os.ModePerm)
|
||||||
|
touch(t, path.Join(d, "x", "a"))
|
||||||
|
touch(t, path.Join(d, "x", "a.todo.xyz"))
|
||||||
|
touch(t, path.Join(d, "x", "b"))
|
||||||
|
},
|
||||||
|
given: "x",
|
||||||
|
want: []string{"a", "a.todo.xyz", "b"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for name, d := range cases {
|
||||||
|
c := d
|
||||||
|
t.Run(name, func(t *testing.T) {
|
||||||
|
d := t.TempDir()
|
||||||
|
if c.setup != nil {
|
||||||
|
c.setup(t, d)
|
||||||
|
}
|
||||||
|
config := config{target: path.Join(d, c.given)}
|
||||||
|
got := config.Targets()
|
||||||
|
for i := range got {
|
||||||
|
got[i] = path.Base(got[i])
|
||||||
|
}
|
||||||
|
for i := range c.want {
|
||||||
|
c.want[i] = path.Base(c.want[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Logf("want\n\t%+v, got \n\t%+v", c.want, got)
|
||||||
|
if len(got) != len(c.want) {
|
||||||
|
t.Error(c.want, got)
|
||||||
|
}
|
||||||
|
for i := range got {
|
||||||
|
if got[i] != c.want[i] {
|
||||||
|
t.Errorf("[%d] wanted %s, got %s", i, c.want[i], got[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
44
cmd/dump.go
Normal file
44
cmd/dump.go
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"gitea.inhome.blapointe.com/gogs/pttodo/pttodo"
|
||||||
|
"gopkg.in/yaml.v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
func dump(config config) error {
|
||||||
|
return _dump(os.Stdout, config.Targets(), config.tags, config.search, config.root)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _dump(writer io.Writer, filepaths []string, tags []string, search, rootDisplay string) error {
|
||||||
|
root, err := pttodo.NewRootFromFiles(filepaths...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, x := range []*[]pttodo.Todo{
|
||||||
|
&root.Todo,
|
||||||
|
&root.Scheduled,
|
||||||
|
&root.Done,
|
||||||
|
} {
|
||||||
|
y := pttodo.Todos(*x)
|
||||||
|
y = y.LikeTags(tags)
|
||||||
|
y = y.LikeSearch(search)
|
||||||
|
*x = y
|
||||||
|
}
|
||||||
|
|
||||||
|
var v interface{} = root
|
||||||
|
switch rootDisplay {
|
||||||
|
case DUMP_TODO:
|
||||||
|
v = root.Todo
|
||||||
|
case DUMP_SCHEDULED:
|
||||||
|
v = root.Scheduled
|
||||||
|
case DUMP_DONE:
|
||||||
|
v = root.Done
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
return yaml.NewEncoder(writer).Encode(v)
|
||||||
|
}
|
||||||
262
cmd/edit.go
Normal file
262
cmd/edit.go
Normal file
@@ -0,0 +1,262 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"path"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
"syscall"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"gitea.inhome.blapointe.com/gogs/pttodo/pttodo"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"gopkg.in/yaml.v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
func edit(config *config) error {
|
||||||
|
if !config.edit {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return _edit(config.Targets())
|
||||||
|
}
|
||||||
|
|
||||||
|
func _edit(filepaths []string) error {
|
||||||
|
editableDir, err := inEditableDirAsTodos(filepaths)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := modifyEditableDir(editableDir, func() error {
|
||||||
|
files, err := listDir(editableDir)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, p := range files {
|
||||||
|
if _, err := pttodo.NewTodosFromFile(p); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
editedFiles, err := listDir(editableDir)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
edits := map[string]string{}
|
||||||
|
for _, editedFile := range editedFiles {
|
||||||
|
edits[path.Base(editedFile)] = editedFile
|
||||||
|
|
||||||
|
edited, err := pttodo.NewTodosFromFile(editedFile)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
original, err := pttodo.NewRootFromFile(func() string {
|
||||||
|
for _, f := range filepaths {
|
||||||
|
if path.Base(f) == path.Base(editedFile) {
|
||||||
|
return f
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "/dev/null"
|
||||||
|
}())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
editedIDs := map[string]int{}
|
||||||
|
for i := range edited {
|
||||||
|
editedIDs[edited[i].ID()] = 1
|
||||||
|
}
|
||||||
|
for i := range original.Todo {
|
||||||
|
if _, ok := editedIDs[original.Todo[i].ID()]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
original.Todo[i].TS = pttodo.TS(time.Now().Unix())
|
||||||
|
if string(original.Todo[i].Schedule) != "" && !original.Todo[i].Triggered() {
|
||||||
|
original.Scheduled = append(original.Scheduled, original.Todo[i])
|
||||||
|
}
|
||||||
|
original.Done = append(original.Done, original.Todo[i])
|
||||||
|
}
|
||||||
|
original.Todo = edited
|
||||||
|
original.AutoMove()
|
||||||
|
|
||||||
|
if err := func() error {
|
||||||
|
f, err := os.Create(editedFile)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
return yaml.NewEncoder(f).Encode(original)
|
||||||
|
}(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dir := ""
|
||||||
|
for _, f := range filepaths {
|
||||||
|
if edited, ok := edits[path.Base(f)]; ok {
|
||||||
|
if err := os.Rename(edited, f); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
delete(edits, path.Base(f))
|
||||||
|
} else if err := os.Remove(f); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
dir = path.Dir(f)
|
||||||
|
}
|
||||||
|
|
||||||
|
for base, editedFile := range edits {
|
||||||
|
f := path.Join(dir, base)
|
||||||
|
if _, err := os.Stat(f); err == nil {
|
||||||
|
f = fmt.Sprintf("%s.todo.%s", f, uuid.New().String())
|
||||||
|
}
|
||||||
|
if err := os.Rename(editedFile, f); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func inEditableDirAsTodos(filepaths []string) (string, error) {
|
||||||
|
tempDir, err := ioutil.TempDir(os.TempDir(), "edit-pttodo-*")
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return tempDir, copyTodoToDir(tempDir, filepaths)
|
||||||
|
}
|
||||||
|
|
||||||
|
func copyTodoToDir(d string, filepaths []string) error {
|
||||||
|
inboxes := map[string][]string{}
|
||||||
|
for _, target := range filepaths {
|
||||||
|
p := path.Join(d, path.Base(target))
|
||||||
|
if strings.Contains(path.Base(target), ".todo.") {
|
||||||
|
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 {
|
||||||
|
return err
|
||||||
|
} else if b, err := yaml.Marshal(root.Todo); err != nil {
|
||||||
|
return err
|
||||||
|
} else if err := os.WriteFile(p, b, os.ModePerm); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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
|
||||||
|
}
|
||||||
|
root.MergeIn(pttodo.Root{Todo: inboxRoot.Todo})
|
||||||
|
root.MergeIn(pttodo.Root{Todo: inboxRoot.Scheduled})
|
||||||
|
|
||||||
|
if b, err := yaml.Marshal(root.Todo); err != nil {
|
||||||
|
return err
|
||||||
|
} else if err := os.WriteFile(p, b, os.ModePerm); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func modifyEditableDir(d string, check func() error) error {
|
||||||
|
for {
|
||||||
|
if err := vimd(d); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err := check()
|
||||||
|
if err == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
log.Printf("%s, press <Enter> to resume editing", err)
|
||||||
|
b := make([]byte, 1)
|
||||||
|
if _, err := os.Stdin.Read(b); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func vimd(d string) error {
|
||||||
|
bin := "vim"
|
||||||
|
editorbin, err := exec.LookPath(bin)
|
||||||
|
if err != nil {
|
||||||
|
editorbin, err = exec.LookPath("vi")
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args := []string{editorbin, "-p"}
|
||||||
|
files, err := listDir(d)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, files...)
|
||||||
|
cpid, err := syscall.ForkExec(
|
||||||
|
editorbin,
|
||||||
|
args,
|
||||||
|
&syscall.ProcAttr{
|
||||||
|
Dir: d,
|
||||||
|
Env: os.Environ(),
|
||||||
|
Files: []uintptr{os.Stdin.Fd(), os.Stdout.Fd(), os.Stderr.Fd()},
|
||||||
|
Sys: nil,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
proc, err := os.FindProcess(cpid)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
state, err := proc.Wait()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if exitCode := state.ExitCode(); exitCode != 0 {
|
||||||
|
return fmt.Errorf("bad exit code on vim: %d, state: %+v", exitCode, state)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func listDir(dname string) ([]string, error) {
|
||||||
|
entries, err := os.ReadDir(dname)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
paths := make([]string, 0, len(entries))
|
||||||
|
for i := range entries {
|
||||||
|
if entries[i].IsDir() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if strings.HasPrefix(path.Base(entries[i].Name()), ".") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
paths = append(paths, path.Join(dname, entries[i].Name()))
|
||||||
|
}
|
||||||
|
sort.Slice(paths, func(i, j int) bool {
|
||||||
|
if path.Base(paths[i]) == "root.yaml" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return paths[i] < paths[j]
|
||||||
|
})
|
||||||
|
return paths, nil
|
||||||
|
}
|
||||||
29
cmd/edit_test.go
Normal file
29
cmd/edit_test.go
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
"strconv"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestListDir(t *testing.T) {
|
||||||
|
d := t.TempDir()
|
||||||
|
want := []string{}
|
||||||
|
for i := 0; i < 3; i++ {
|
||||||
|
p := path.Join(d, strconv.Itoa(i))
|
||||||
|
ioutil.WriteFile(p, []byte{}, os.ModePerm)
|
||||||
|
want = append(want, p)
|
||||||
|
}
|
||||||
|
os.Mkdir(path.Join(d, "d"), os.ModePerm)
|
||||||
|
|
||||||
|
got, err := listDir(d)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if fmt.Sprint(want) != fmt.Sprint(got) {
|
||||||
|
t.Fatal(want, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
13
cmd/go.mod
Normal file
13
cmd/go.mod
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
module pttodo-cli
|
||||||
|
|
||||||
|
go 1.17
|
||||||
|
|
||||||
|
require (
|
||||||
|
gitea.inhome.blapointe.com/gogs/pttodo v0.0.0-20231109151914-5d74b458d542
|
||||||
|
github.com/google/uuid v1.3.0
|
||||||
|
gopkg.in/yaml.v2 v2.4.0
|
||||||
|
)
|
||||||
|
|
||||||
|
require github.com/robfig/cron/v3 v3.0.1 // indirect
|
||||||
|
|
||||||
|
replace gogs.inhome.blapointe.com/gogs/pttodo => ./..
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
|
gitea.inhome.blapointe.com/gogs/pttodo v0.0.0-20231109151914-5d74b458d542 h1:eOWrA2hEQoyu413vbdXbEXHLXEX2TVBXjWawlWndFhg=
|
||||||
|
gitea.inhome.blapointe.com/gogs/pttodo v0.0.0-20231109151914-5d74b458d542/go.mod h1:9CFZf/SSod0Z/8WvbmOI4gEzy6xGpBQAq8coVNncNvk=
|
||||||
|
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||||
|
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
20
cmd/install.sh
Normal file
20
cmd/install.sh
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
cd "$(dirname "$BASH_SOURCE")"
|
||||||
|
|
||||||
|
binary_name="$(head -n 1 go.mod | awk '{print $NF}' | sed 's/.*\///')"
|
||||||
|
git_commit="$((
|
||||||
|
git rev-list -1 HEAD
|
||||||
|
if git diff | grep . > /dev/null; then
|
||||||
|
echo "-dirty"
|
||||||
|
fi
|
||||||
|
) 2> /dev/null | tr -d '\n')"
|
||||||
|
|
||||||
|
GOFLAGS="" \
|
||||||
|
GO111MODULE="" \
|
||||||
|
CGO_ENABLED=0 \
|
||||||
|
go build \
|
||||||
|
-o $GOPATH/bin/$binary_name \
|
||||||
|
-a \
|
||||||
|
-installsuffix cgo \
|
||||||
|
-ldflags "-s -w -X main.GitCommit=$git_commit"
|
||||||
102
cmd/main.go
Normal file
102
cmd/main.go
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"gitea.inhome.blapointe.com/gogs/pttodo/pttodo"
|
||||||
|
|
||||||
|
"gopkg.in/yaml.v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
DUMP_ALL = "all"
|
||||||
|
DUMP_TODO = "todo"
|
||||||
|
DUMP_SCHEDULED = "scheduled"
|
||||||
|
DUMP_DONE = "done"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
if err := _main(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func _main() error {
|
||||||
|
config := getConfig()
|
||||||
|
if err := add(&config); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := edit(&config); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return dump(config)
|
||||||
|
}
|
||||||
|
|
||||||
|
func merge(filepath string, mergeTargetFilePath string) error {
|
||||||
|
baseReader, err := filePathReader(filepath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
baseB, err := ioutil.ReadAll(baseReader)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
mergingReader, err := filePathReader(mergeTargetFilePath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
mergingB, err := ioutil.ReadAll(mergingReader)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var base, merging pttodo.Root
|
||||||
|
if err := yaml.Unmarshal(baseB, &base); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := yaml.Unmarshal(mergingB, &merging); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
base.MergeIn(merging)
|
||||||
|
|
||||||
|
tmppath, err := marshalRootToTempFile(base)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return os.Rename(tmppath, filepath)
|
||||||
|
}
|
||||||
|
|
||||||
|
func marshalRootToTempFile(root pttodo.Root) (string, error) {
|
||||||
|
f, err := ioutil.TempFile(os.TempDir(), "tmp")
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
f.Close()
|
||||||
|
os.Remove(f.Name())
|
||||||
|
b, err := yaml.Marshal(root)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
filepath := f.Name() + ".yaml"
|
||||||
|
err = ioutil.WriteFile(filepath, b, os.ModePerm)
|
||||||
|
return filepath, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func filePathReader(path string) (io.Reader, error) {
|
||||||
|
if path == "-" {
|
||||||
|
return os.Stdin, nil
|
||||||
|
}
|
||||||
|
b, err := ioutil.ReadFile(path)
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
return bytes.NewReader([]byte("{}")), nil
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return bytes.NewReader(b), nil
|
||||||
|
}
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"flag"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
|
||||||
"local/pt-todo-server/pttodo"
|
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
"path"
|
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"gopkg.in/yaml.v2"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
if err := _main(); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func _main() error {
|
|
||||||
filepath := flag.String("f", "-", "path to yaml file")
|
|
||||||
e := flag.Bool("e", false, "edit file")
|
|
||||||
flag.Parse()
|
|
||||||
if *e {
|
|
||||||
if err := edit(*filepath); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dump(os.Stdout, *filepath)
|
|
||||||
}
|
|
||||||
|
|
||||||
func edit(filepath string) error {
|
|
||||||
var tempFile string
|
|
||||||
cp := func() error {
|
|
||||||
f, err := ioutil.TempFile(os.TempDir(), path.Base(filepath))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
g, err := os.Open(filepath)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if _, err := io.Copy(f, g); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
g.Close()
|
|
||||||
f.Close()
|
|
||||||
tempFile = f.Name()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
vi := func() error {
|
|
||||||
vibin, err := exec.LookPath("vi")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
cpid, err := syscall.ForkExec(
|
|
||||||
vibin,
|
|
||||||
[]string{vibin, tempFile},
|
|
||||||
&syscall.ProcAttr{
|
|
||||||
Dir: "",
|
|
||||||
Env: os.Environ(),
|
|
||||||
Files: []uintptr{os.Stdin.Fd(), os.Stdout.Fd(), os.Stderr.Fd()},
|
|
||||||
Sys: nil,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
proc, err := os.FindProcess(cpid)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
state, err := proc.Wait()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if exitCode := state.ExitCode(); exitCode != 0 {
|
|
||||||
return fmt.Errorf("bad exit code on vim: %d, state: %+v", exitCode, state)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
verify := func() error {
|
|
||||||
return dump(io.Discard, tempFile)
|
|
||||||
}
|
|
||||||
save := func() error {
|
|
||||||
return os.Rename(tempFile, filepath)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, foo := range []func() error{cp, vi, verify, save} {
|
|
||||||
if err := foo(); err != nil {
|
|
||||||
if tempFile != "" {
|
|
||||||
os.Remove(tempFile)
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func dump(writer io.Writer, filepath string) error {
|
|
||||||
var reader io.Reader
|
|
||||||
if filepath == "-" {
|
|
||||||
reader = os.Stdin
|
|
||||||
} else {
|
|
||||||
b, err := ioutil.ReadFile(filepath)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
reader = bytes.NewReader(b)
|
|
||||||
}
|
|
||||||
|
|
||||||
b, err := ioutil.ReadAll(reader)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
var root pttodo.Root
|
|
||||||
if err := yaml.Unmarshal(b, &root); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
root.MoveScheduledToTodo()
|
|
||||||
|
|
||||||
b2, err := yaml.Marshal(root)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
fmt.Fprintf(writer, "%s\n", b2)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
module pttodo
|
|
||||||
|
|
||||||
go 1.17
|
|
||||||
|
|
||||||
require (
|
|
||||||
gopkg.in/yaml.v2 v2.4.0
|
|
||||||
local/pt-todo-server v0.0.0-00010101000000-000000000000
|
|
||||||
)
|
|
||||||
|
|
||||||
require github.com/robfig/cron/v3 v3.0.1 // indirect
|
|
||||||
|
|
||||||
replace local/pt-todo-server => ../../
|
|
||||||
4
cmd/testdata/1.yaml
vendored
Executable file
4
cmd/testdata/1.yaml
vendored
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
todo:
|
||||||
|
- "1"
|
||||||
|
scheduled: []
|
||||||
|
done: []
|
||||||
4
cmd/testdata/2.yaml
vendored
Executable file
4
cmd/testdata/2.yaml
vendored
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
todo:
|
||||||
|
- "2"
|
||||||
|
scheduled: []
|
||||||
|
done: []
|
||||||
4
cmd/testdata/3.yaml
vendored
Executable file
4
cmd/testdata/3.yaml
vendored
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
todo:
|
||||||
|
- "3"
|
||||||
|
scheduled: []
|
||||||
|
done: []
|
||||||
17
cmd/testdata/root.yaml
vendored
Executable file
17
cmd/testdata/root.yaml
vendored
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
todo:
|
||||||
|
- root
|
||||||
|
- stub
|
||||||
|
scheduled:
|
||||||
|
- todo: abc
|
||||||
|
schedule: "2024-01-01"
|
||||||
|
ts: Thu Nov 9 07:49:59 MST 2023
|
||||||
|
- todo: "1"
|
||||||
|
schedule: "2024-01-02"
|
||||||
|
ts: Thu Nov 9 07:51:13 MST 2023
|
||||||
|
- todo: "1"
|
||||||
|
schedule: "2024-01-02"
|
||||||
|
ts: Thu Nov 9 07:51:28 MST 2023
|
||||||
|
- todo: "1"
|
||||||
|
schedule: "2024-01-02"
|
||||||
|
ts: Thu Nov 9 07:51:36 MST 2023
|
||||||
|
done: []
|
||||||
10
cmd/testdata/test.yaml
vendored
Executable file
10
cmd/testdata/test.yaml
vendored
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
todo:
|
||||||
|
- hi20890
|
||||||
|
- hi
|
||||||
|
- b
|
||||||
|
- todo: loop
|
||||||
|
schedule: 10s
|
||||||
|
- todo: past
|
||||||
|
schedule: "2000-01-02"
|
||||||
|
scheduled: []
|
||||||
|
done: []
|
||||||
2
go.mod
2
go.mod
@@ -1,4 +1,4 @@
|
|||||||
module local/pt-todo-server
|
module gitea.inhome.blapointe.com/gogs/pttodo
|
||||||
|
|
||||||
go 1.17
|
go 1.17
|
||||||
|
|
||||||
|
|||||||
111
pttodo/root.go
111
pttodo/root.go
@@ -1,11 +1,90 @@
|
|||||||
package pttodo
|
package pttodo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
yaml "gopkg.in/yaml.v2"
|
||||||
|
)
|
||||||
|
|
||||||
type Root struct {
|
type Root struct {
|
||||||
Todo []Todo
|
Todo []Todo
|
||||||
Scheduled []Todo
|
Scheduled []Todo
|
||||||
Done []Todo
|
Done []Todo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewRootFromFiles(p ...string) (Root, error) {
|
||||||
|
var result Root
|
||||||
|
for _, p := range p {
|
||||||
|
subroot, err := NewRootFromFile(p)
|
||||||
|
if err != nil {
|
||||||
|
return Root{}, err
|
||||||
|
}
|
||||||
|
result.MergeIn(subroot)
|
||||||
|
}
|
||||||
|
result.AutoMove()
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewRootFromFile(p string) (Root, error) {
|
||||||
|
if b, err := os.ReadFile(p); err == nil && len(bytes.TrimSpace(b)) == 0 {
|
||||||
|
return Root{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
f, err := os.Open(p)
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
return Root{}, nil
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return Root{}, err
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
var result Root
|
||||||
|
if err := yaml.NewDecoder(f).Decode(&result); err != nil {
|
||||||
|
todos, err2 := NewTodosFromFile(p)
|
||||||
|
if err2 != nil {
|
||||||
|
return Root{}, err
|
||||||
|
}
|
||||||
|
result.Todo = todos
|
||||||
|
}
|
||||||
|
|
||||||
|
result.AutoMove()
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (root Root) Equals(other Root) bool {
|
||||||
|
for i, slice := range [][2][]Todo{
|
||||||
|
[2][]Todo{root.Todo, other.Todo},
|
||||||
|
[2][]Todo{root.Scheduled, other.Scheduled},
|
||||||
|
[2][]Todo{root.Done, other.Done},
|
||||||
|
} {
|
||||||
|
_ = i
|
||||||
|
if !equalTodoSlices(slice[0], slice[1]) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (root *Root) AutoMove() {
|
||||||
|
root.MoveScheduledToTodo()
|
||||||
|
root.MoveTodoToScheduled()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (root *Root) MoveTodoToScheduled() {
|
||||||
|
for i := len(root.Todo) - 1; i >= 0; i-- {
|
||||||
|
if !root.Todo[i].Schedule.isFixedFuture() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
root.Scheduled = append(root.Scheduled, root.Todo[i])
|
||||||
|
for j := i; j < len(root.Todo)-1; j++ {
|
||||||
|
root.Todo[j] = root.Todo[j+1]
|
||||||
|
}
|
||||||
|
root.Todo = root.Todo[:len(root.Todo)-1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (root *Root) MoveScheduledToTodo() {
|
func (root *Root) MoveScheduledToTodo() {
|
||||||
for i := len(root.Scheduled) - 1; i >= 0; i-- {
|
for i := len(root.Scheduled) - 1; i >= 0; i-- {
|
||||||
if root.Scheduled[i].Triggered() {
|
if root.Scheduled[i].Triggered() {
|
||||||
@@ -18,3 +97,35 @@ func (root *Root) MoveScheduledToTodo() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (root *Root) MergeIn(root2 Root) {
|
||||||
|
for _, listPair := range [][2]*[]Todo{
|
||||||
|
[2]*[]Todo{&root.Todo, &root2.Todo},
|
||||||
|
[2]*[]Todo{&root.Scheduled, &root2.Scheduled},
|
||||||
|
[2]*[]Todo{&root.Done, &root2.Done},
|
||||||
|
} {
|
||||||
|
for _, candidate := range *listPair[1] {
|
||||||
|
found := false
|
||||||
|
for i := range *listPair[0] {
|
||||||
|
found = found || ((*listPair[0])[i].Todo == candidate.Todo)
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
*listPair[0] = append(*listPair[0], candidate)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (root Root) MarshalYAML() (interface{}, error) {
|
||||||
|
for i := range root.Todo {
|
||||||
|
root.Todo[i].writeTS = false
|
||||||
|
}
|
||||||
|
for i := range root.Scheduled {
|
||||||
|
root.Scheduled[i].writeTS = true
|
||||||
|
}
|
||||||
|
for i := range root.Done {
|
||||||
|
root.Done[i].writeTS = true
|
||||||
|
}
|
||||||
|
type Alt Root
|
||||||
|
return (Alt)(root), nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
package pttodo
|
package pttodo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
yaml "gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestJSONRoot(t *testing.T) {
|
func TestJSONRoot(t *testing.T) {
|
||||||
@@ -21,6 +27,8 @@ func TestJSONRoot(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
} else if fmt.Sprint(root) != fmt.Sprint(root2) {
|
} else if fmt.Sprint(root) != fmt.Sprint(root2) {
|
||||||
t.Fatal(root, root2)
|
t.Fatal(root, root2)
|
||||||
|
} else if !root.Equals(root2) {
|
||||||
|
t.Fatal(root2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +100,160 @@ func TestRootMoveScheduledToTodo(t *testing.T) {
|
|||||||
got.MoveScheduledToTodo()
|
got.MoveScheduledToTodo()
|
||||||
if fmt.Sprintf("%+v", got) != fmt.Sprintf("%+v", want) {
|
if fmt.Sprintf("%+v", got) != fmt.Sprintf("%+v", want) {
|
||||||
t.Fatalf("want \n\t%+v, got \n\t%+v", want, got)
|
t.Fatalf("want \n\t%+v, got \n\t%+v", want, got)
|
||||||
|
} else if !got.Equals(want) {
|
||||||
|
t.Fatalf("want \n\t%+v, got \n\t%+v", want, got)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMergeRoots(t *testing.T) {
|
||||||
|
root0yaml := `
|
||||||
|
todo:
|
||||||
|
- a
|
||||||
|
- b
|
||||||
|
- todo: c
|
||||||
|
- todo: d
|
||||||
|
tags: a
|
||||||
|
- exclusive to 0
|
||||||
|
`
|
||||||
|
root1yaml := `
|
||||||
|
todo:
|
||||||
|
- a
|
||||||
|
- b
|
||||||
|
- todo: c
|
||||||
|
- todo: d
|
||||||
|
tags: b
|
||||||
|
- exclusive to 1
|
||||||
|
`
|
||||||
|
rootWantyaml := `
|
||||||
|
todo:
|
||||||
|
- a
|
||||||
|
- b
|
||||||
|
- todo: c
|
||||||
|
- todo: d
|
||||||
|
tags: a
|
||||||
|
- exclusive to 0
|
||||||
|
- exclusive to 1
|
||||||
|
`
|
||||||
|
|
||||||
|
var root0, root1, rootWant Root
|
||||||
|
if err := yaml.Unmarshal([]byte(root0yaml), &root0); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := yaml.Unmarshal([]byte(root1yaml), &root1); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := yaml.Unmarshal([]byte(rootWantyaml), &rootWant); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
root0.MergeIn(root1)
|
||||||
|
if fmt.Sprintf("%+v", root0) != fmt.Sprintf("%+v", rootWant) {
|
||||||
|
t.Fatalf("want \n\t%+v, got \n\t%+v", rootWant, root0)
|
||||||
|
} else if !root0.Equals(rootWant) {
|
||||||
|
t.Fatalf("want \n\t%+v, got \n\t%+v", rootWant, root0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRootMarshalYAMLWriteTS(t *testing.T) {
|
||||||
|
root := Root{
|
||||||
|
Todo: []Todo{Todo{Todo: "todo", TS: 1, writeTS: true}},
|
||||||
|
Scheduled: []Todo{Todo{Todo: "sched", TS: 2, writeTS: false, Schedule: "2099-01-01"}},
|
||||||
|
Done: []Todo{Todo{Todo: "done", TS: 3, writeTS: false}},
|
||||||
|
}
|
||||||
|
got, err := yaml.Marshal(root)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
got = bytes.TrimSpace(got)
|
||||||
|
want := strings.TrimSpace(`
|
||||||
|
todo:
|
||||||
|
- todo
|
||||||
|
scheduled:
|
||||||
|
- todo: sched
|
||||||
|
schedule: "2099-01-01"
|
||||||
|
ts: Wed Dec 31 17:00:02 MST 1969
|
||||||
|
done:
|
||||||
|
- todo: done
|
||||||
|
ts: Wed Dec 31 17:00:03 MST 1969
|
||||||
|
`)
|
||||||
|
if string(got) != want {
|
||||||
|
t.Fatalf("want\n\t%q, got\n\t%q", want, string(got))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRootFromFile(t *testing.T) {
|
||||||
|
cases := map[string]struct {
|
||||||
|
given string
|
||||||
|
want Root
|
||||||
|
}{
|
||||||
|
"empty": {},
|
||||||
|
"happy": {
|
||||||
|
given: `{"todo":["a", "b"],"scheduled":["c"], "done":[{"todo": "d"}]}`,
|
||||||
|
want: Root{
|
||||||
|
Todo: []Todo{
|
||||||
|
Todo{Todo: "a"},
|
||||||
|
Todo{Todo: "b"},
|
||||||
|
},
|
||||||
|
Scheduled: []Todo{
|
||||||
|
Todo{Todo: "c"},
|
||||||
|
},
|
||||||
|
Done: []Todo{
|
||||||
|
Todo{Todo: "d"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"todos": {
|
||||||
|
given: `["a", {"todo": "b"}]`,
|
||||||
|
want: Root{
|
||||||
|
Todo: []Todo{
|
||||||
|
{Todo: "a"},
|
||||||
|
{Todo: "b"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for name, d := range cases {
|
||||||
|
c := d
|
||||||
|
t.Run(name, func(t *testing.T) {
|
||||||
|
d := t.TempDir()
|
||||||
|
p := path.Join(d, "input.yaml")
|
||||||
|
if err := os.WriteFile(p, []byte(c.given), os.ModePerm); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
got, err := NewRootFromFile(p)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if fmt.Sprintf("%+v", got) != fmt.Sprintf("%+v", c.want) {
|
||||||
|
t.Errorf("want\n\t%+v, got\n\t%+v", c.want, got)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRootFromFiles(t *testing.T) {
|
||||||
|
d := t.TempDir()
|
||||||
|
ps := []string{
|
||||||
|
path.Join(d, "a"),
|
||||||
|
path.Join(d, "b"),
|
||||||
|
}
|
||||||
|
os.WriteFile(ps[0], []byte(`["a"]`), os.ModePerm)
|
||||||
|
os.WriteFile(ps[1], []byte(`["b"]`), os.ModePerm)
|
||||||
|
|
||||||
|
got, err := NewRootFromFiles(ps...)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
want := Root{
|
||||||
|
Todo: []Todo{
|
||||||
|
{Todo: "a"},
|
||||||
|
{Todo: "b"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if fmt.Sprintf("%+v", got) != fmt.Sprintf("%+v", want) {
|
||||||
|
t.Errorf("want\n\t%+v, got \n\t%+v", want, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -25,6 +25,42 @@ func (schedule Schedule) Next(t time.Time) (time.Time, error) {
|
|||||||
return scheduler.next(t)
|
return scheduler.next(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (schedule Schedule) isFixedFuture() bool {
|
||||||
|
if !schedule.isFixed() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return schedule.isFuture()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (schedule Schedule) isFixed() bool {
|
||||||
|
if schedule.empty() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
scheduler := schedulerFactory(string(schedule))
|
||||||
|
switch scheduler.(type) {
|
||||||
|
case scheduleEZDate, scheduleDue:
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (schedule Schedule) isFuture() bool {
|
||||||
|
if schedule.empty() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
scheduler := schedulerFactory(string(schedule))
|
||||||
|
t, err := scheduler.next(time.Now())
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return time.Now().Before(t)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (schedule Schedule) empty() bool {
|
||||||
|
return string(schedule) == ""
|
||||||
|
}
|
||||||
|
|
||||||
type scheduler interface {
|
type scheduler interface {
|
||||||
next(time.Time) (time.Time, error)
|
next(time.Time) (time.Time, error)
|
||||||
}
|
}
|
||||||
@@ -37,6 +73,8 @@ func schedulerFactory(s string) scheduler {
|
|||||||
} else if scheduleDuePattern.MatchString(s) {
|
} else if scheduleDuePattern.MatchString(s) {
|
||||||
n, _ := strconv.Atoi(s)
|
n, _ := strconv.Atoi(s)
|
||||||
return scheduleDue(n)
|
return scheduleDue(n)
|
||||||
|
} else if scheduleEZDatePattern.MatchString(s) {
|
||||||
|
return scheduleEZDate(s)
|
||||||
}
|
}
|
||||||
return scheduleCron(s)
|
return scheduleCron(s)
|
||||||
}
|
}
|
||||||
@@ -88,3 +126,15 @@ var scheduleDuePattern = regexp.MustCompile(`^[0-9]+$`)
|
|||||||
func (due scheduleDue) next(time.Time) (time.Time, error) {
|
func (due scheduleDue) next(time.Time) (time.Time, error) {
|
||||||
return TS(due).time(), nil
|
return TS(due).time(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2022-01-01
|
||||||
|
type scheduleEZDate string
|
||||||
|
|
||||||
|
var scheduleEZDatePattern = regexp.MustCompile(`^[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2})?$`)
|
||||||
|
|
||||||
|
func (ezdate scheduleEZDate) next(time.Time) (time.Time, error) {
|
||||||
|
if len(ezdate) == len("20xx-xx-xxTxx") {
|
||||||
|
return time.ParseInLocation("2006-01-02T15", string(ezdate), time.Local)
|
||||||
|
}
|
||||||
|
return time.ParseInLocation("2006-01-02", string(ezdate), time.Local)
|
||||||
|
}
|
||||||
|
|||||||
@@ -50,11 +50,18 @@ func TestJSONSchedule(t *testing.T) {
|
|||||||
|
|
||||||
func TestSchedulerFactory(t *testing.T) {
|
func TestSchedulerFactory(t *testing.T) {
|
||||||
start := time.Date(2000, 1, 1, 1, 1, 1, 1, time.UTC)
|
start := time.Date(2000, 1, 1, 1, 1, 1, 1, time.UTC)
|
||||||
|
someDay := time.Date(2001, 2, 3, 0, 0, 0, 0, time.UTC)
|
||||||
|
someHour := time.Date(2001, 2, 3, 15, 0, 0, 0, time.UTC)
|
||||||
cases := map[string]struct {
|
cases := map[string]struct {
|
||||||
input string
|
input string
|
||||||
want interface{}
|
want interface{}
|
||||||
next time.Time
|
next time.Time
|
||||||
}{
|
}{
|
||||||
|
"ezdate with hour": {
|
||||||
|
input: `2000-01-03T15`,
|
||||||
|
want: scheduleEZDate(`2000-01-03T15`),
|
||||||
|
next: someHour,
|
||||||
|
},
|
||||||
"long dur": {
|
"long dur": {
|
||||||
input: `2h1m`,
|
input: `2h1m`,
|
||||||
want: scheduleDuration("2h1m"),
|
want: scheduleDuration("2h1m"),
|
||||||
@@ -70,11 +77,6 @@ func TestSchedulerFactory(t *testing.T) {
|
|||||||
want: scheduleDue(1),
|
want: scheduleDue(1),
|
||||||
next: time.Unix(1, 0),
|
next: time.Unix(1, 0),
|
||||||
},
|
},
|
||||||
"zero ts": {
|
|
||||||
input: `0`,
|
|
||||||
want: scheduleDue(0),
|
|
||||||
next: time.Unix(0, 0),
|
|
||||||
},
|
|
||||||
"never": {
|
"never": {
|
||||||
input: ``,
|
input: ``,
|
||||||
want: scheduleNever{},
|
want: scheduleNever{},
|
||||||
@@ -90,6 +92,11 @@ func TestSchedulerFactory(t *testing.T) {
|
|||||||
want: scheduleCron(`5 * * * *`),
|
want: scheduleCron(`5 * * * *`),
|
||||||
next: start.Add(time.Duration(-1*start.Nanosecond() + -1*start.Minute() + -1*start.Second())).Add(5 * time.Minute),
|
next: start.Add(time.Duration(-1*start.Nanosecond() + -1*start.Minute() + -1*start.Second())).Add(5 * time.Minute),
|
||||||
},
|
},
|
||||||
|
"ezdate": {
|
||||||
|
input: `2000-01-03`,
|
||||||
|
want: scheduleEZDate(`2000-01-03`),
|
||||||
|
next: someDay,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, d := range cases {
|
for name, d := range cases {
|
||||||
@@ -108,4 +115,75 @@ func TestSchedulerFactory(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t.Run("zero ts", func(t *testing.T) {
|
||||||
|
got := schedulerFactory("0")
|
||||||
|
if fmt.Sprintf("%T", scheduleDue(0)) != fmt.Sprintf("%T", got) {
|
||||||
|
t.Fatalf("want type %T, got %T", scheduleDue(0), got)
|
||||||
|
}
|
||||||
|
if fmt.Sprint(scheduleDue(0)) != fmt.Sprint(got) {
|
||||||
|
t.Fatalf("want %+v, got %+v", scheduleDue(0), got)
|
||||||
|
}
|
||||||
|
next, _ := got.next(start)
|
||||||
|
if now := time.Now(); next.Sub(now) > time.Second {
|
||||||
|
t.Fatalf("want next %+v, got %+v", now, next)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestScheduleIsFixedFuture(t *testing.T) {
|
||||||
|
cases := map[string]struct {
|
||||||
|
input string
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
"empty": {
|
||||||
|
input: "",
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
"cron": {
|
||||||
|
input: "* * * * *",
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
"duration": {
|
||||||
|
input: "1m",
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
"due past": {
|
||||||
|
input: "123",
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
"due future": {
|
||||||
|
input: "9648154541",
|
||||||
|
want: true,
|
||||||
|
},
|
||||||
|
"ez date short past": {
|
||||||
|
input: "2000-01-02",
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
"ez date short future": {
|
||||||
|
input: "2100-01-02",
|
||||||
|
want: true,
|
||||||
|
},
|
||||||
|
"ez date long past": {
|
||||||
|
input: "2000-01-02T01",
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
"ez date long future": {
|
||||||
|
input: "2100-01-02T02",
|
||||||
|
want: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for name, d := range cases {
|
||||||
|
c := d
|
||||||
|
t.Run(name, func(t *testing.T) {
|
||||||
|
schedule := Schedule(c.input)
|
||||||
|
got := schedule.isFixedFuture()
|
||||||
|
if got != c.want {
|
||||||
|
gotFuture := schedule.isFuture()
|
||||||
|
gotFixed := schedule.isFixed()
|
||||||
|
t.Errorf("want %v, got %v = %v && %v", c.want, got, gotFuture, gotFixed)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,53 @@
|
|||||||
package pttodo
|
package pttodo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"hash/crc32"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
yaml "gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Todo struct {
|
type Todo struct {
|
||||||
Todo string
|
Todo string
|
||||||
Details string `yaml:",omitempty"`
|
Details string `yaml:",omitempty"`
|
||||||
TS TS `yaml:",omitempty"`
|
|
||||||
Schedule Schedule `yaml:",omitempty"`
|
Schedule Schedule `yaml:",omitempty"`
|
||||||
Tags string `yaml:",omitempty"`
|
Tags string `yaml:",omitempty"`
|
||||||
Subtasks []Todo `yaml:",omitempty"`
|
Subtasks []Todo `yaml:",omitempty"`
|
||||||
|
TS TS `yaml:",omitempty"`
|
||||||
|
writeTS bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewTodosFromFile(p string) ([]Todo, error) {
|
||||||
|
f, err := os.Open(p)
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
var result []Todo
|
||||||
|
if err := yaml.NewDecoder(f).Decode(&result); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (todo Todo) ID() string {
|
||||||
|
hash := crc32.NewIEEE()
|
||||||
|
fmt.Fprintf(hash, "%d:%s", 0, todo.Todo)
|
||||||
|
fmt.Fprintf(hash, "%d:%s", 1, todo.Details)
|
||||||
|
fmt.Fprintf(hash, "%d:%s", 2, todo.Schedule)
|
||||||
|
fmt.Fprintf(hash, "%d:%s", 3, todo.Tags)
|
||||||
|
for i := range todo.Subtasks {
|
||||||
|
fmt.Fprintf(hash, "%d:%s", 4, todo.Subtasks[i].ID())
|
||||||
|
}
|
||||||
|
return base64.StdEncoding.EncodeToString(hash.Sum(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (todo Todo) Triggered() bool {
|
func (todo Todo) Triggered() bool {
|
||||||
@@ -21,6 +57,11 @@ func (todo Todo) Triggered() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (todo Todo) MarshalYAML() (interface{}, error) {
|
func (todo Todo) MarshalYAML() (interface{}, error) {
|
||||||
|
if !todo.writeTS {
|
||||||
|
todo.TS = 0
|
||||||
|
} else {
|
||||||
|
todo.TS = TS(todo.TS.time().Unix())
|
||||||
|
}
|
||||||
if fmt.Sprint(todo) == fmt.Sprint(Todo{Todo: todo.Todo}) {
|
if fmt.Sprint(todo) == fmt.Sprint(Todo{Todo: todo.Todo}) {
|
||||||
return todo.Todo, nil
|
return todo.Todo, nil
|
||||||
}
|
}
|
||||||
@@ -37,3 +78,37 @@ func (todo *Todo) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||||||
alt := (*Alt)(todo)
|
alt := (*Alt)(todo)
|
||||||
return unmarshal(alt)
|
return unmarshal(alt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (todo Todo) Equals(other Todo) bool {
|
||||||
|
if !equalTodoSlices(todo.Subtasks, other.Subtasks) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if todo.TS != other.TS {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if todo.Tags != other.Tags {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if todo.Schedule != other.Schedule {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if todo.Details != other.Details {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if todo.Todo != other.Todo {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func equalTodoSlices(a, b []Todo) bool {
|
||||||
|
if len(a) != len(b) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for i := range a {
|
||||||
|
if !a[i].Equals(b[i]) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|||||||
@@ -125,3 +125,33 @@ func TestMarshalTodo(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTodoID(t *testing.T) {
|
||||||
|
cases := map[string]Todo{
|
||||||
|
"empty": Todo{},
|
||||||
|
"todo": Todo{Todo: "abc"},
|
||||||
|
"details": Todo{Details: "abc"},
|
||||||
|
"todo,details": Todo{Todo: "abc", Details: "abc"},
|
||||||
|
}
|
||||||
|
|
||||||
|
got := map[string]bool{}
|
||||||
|
for name, todod := range cases {
|
||||||
|
todo := todod
|
||||||
|
t.Run(name, func(t *testing.T) {
|
||||||
|
if _, ok := got[todo.ID()]; ok {
|
||||||
|
t.Error("dupe", todo.ID())
|
||||||
|
}
|
||||||
|
got[todo.ID()] = true
|
||||||
|
t.Logf("%s: %+v", todo.ID(), todo)
|
||||||
|
todo2 := todo
|
||||||
|
todo2.TS = 1
|
||||||
|
if todo.ID() != todo2.ID() {
|
||||||
|
t.Error("ts changed")
|
||||||
|
}
|
||||||
|
todo2.writeTS = true
|
||||||
|
if todo.ID() != todo2.ID() {
|
||||||
|
t.Error("writets changed")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
36
pttodo/todos.go
Normal file
36
pttodo/todos.go
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package pttodo
|
||||||
|
|
||||||
|
import "strings"
|
||||||
|
|
||||||
|
type Todos []Todo
|
||||||
|
|
||||||
|
func (todos Todos) LikeSearch(search string) Todos {
|
||||||
|
return todos.Like(func(todo Todo) bool {
|
||||||
|
return strings.Contains(
|
||||||
|
strings.ToLower(todo.Todo),
|
||||||
|
strings.ToLower(search),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (todos Todos) LikeTags(tags []string) Todos {
|
||||||
|
return todos.Like(func(todo Todo) bool {
|
||||||
|
matches := true
|
||||||
|
for _, tag := range tags {
|
||||||
|
str := strings.TrimLeft(tag, "-")
|
||||||
|
want := !strings.HasPrefix(tag, "-")
|
||||||
|
matches = matches && strings.Contains(todo.Tags, str) == want
|
||||||
|
}
|
||||||
|
return matches
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (todos Todos) Like(like func(Todo) bool) Todos {
|
||||||
|
result := make(Todos, 0)
|
||||||
|
for i := range todos {
|
||||||
|
if like(todos[i]) {
|
||||||
|
result = append(result, todos[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
17
pttodo/todos_test.go
Normal file
17
pttodo/todos_test.go
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package pttodo
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestTodosLikeTags(t *testing.T) {
|
||||||
|
todos := Todos{
|
||||||
|
{Todo: "a", Tags: "x"},
|
||||||
|
{Todo: "b", Tags: "x,y"},
|
||||||
|
}
|
||||||
|
|
||||||
|
result := todos.LikeTags([]string{"x", "-y"})
|
||||||
|
if len(result) != 1 {
|
||||||
|
t.Error(result)
|
||||||
|
} else if result[0].Todo != "a" {
|
||||||
|
t.Error(result[0].Todo)
|
||||||
|
}
|
||||||
|
}
|
||||||
25
pttodo/ts.go
25
pttodo/ts.go
@@ -2,12 +2,18 @@ package pttodo
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
yaml "gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TS int64
|
type TS int64
|
||||||
|
|
||||||
func (ts TS) time() time.Time {
|
func (ts TS) time() time.Time {
|
||||||
|
if ts == 0 {
|
||||||
|
ts = TS(time.Now().Unix())
|
||||||
|
}
|
||||||
return time.Unix(int64(ts), 0)
|
return time.Unix(int64(ts), 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,9 +29,24 @@ func (ts TS) MarshalYAML() (interface{}, error) {
|
|||||||
if ts == 0 {
|
if ts == 0 {
|
||||||
ts = TS(time.Now().Unix())
|
ts = TS(time.Now().Unix())
|
||||||
}
|
}
|
||||||
return int64(ts), nil
|
return ts.time().Format(time.UnixDate), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ts *TS) UnmarshalJSON(b []byte) error {
|
func (ts *TS) UnmarshalJSON(b []byte) error {
|
||||||
return json.Unmarshal(b, (*int64)(ts))
|
return yaml.Unmarshal(b, ts)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ts *TS) UnmarshalYAML(unmarshaller func(interface{}) error) error {
|
||||||
|
var n int64
|
||||||
|
if err := unmarshaller(&n); err == nil {
|
||||||
|
*ts = TS(n)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
var s string
|
||||||
|
if err := unmarshaller(&s); err == nil {
|
||||||
|
t, err := time.ParseInLocation(time.UnixDate, s, time.Local)
|
||||||
|
*ts = TS(t.Unix())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return errors.New("illegal TS")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,41 @@ package pttodo
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
yaml "gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestTSMarshalYaml(t *testing.T) {
|
||||||
|
t.Run("nonzero", func(t *testing.T) {
|
||||||
|
var ts TS
|
||||||
|
if b, err := yaml.Marshal(TS(5)); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
} else if s := string(b); !strings.HasSuffix(strings.TrimSpace(s), ` 1969`) {
|
||||||
|
t.Fatal(s)
|
||||||
|
} else if err := yaml.Unmarshal(b, &ts); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
} else if ts != 5 {
|
||||||
|
t.Fatal(ts)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
t.Run("zero", func(t *testing.T) {
|
||||||
|
var ts TS
|
||||||
|
if b, err := yaml.Marshal(TS(0)); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
} else if s := string(b); strings.TrimSpace(s) == `0` {
|
||||||
|
t.Fatal(s)
|
||||||
|
} else if err := yaml.Unmarshal(b, &ts); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
} else if ts == 0 {
|
||||||
|
t.Fatal(ts)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestJSONTS(t *testing.T) {
|
func TestJSONTS(t *testing.T) {
|
||||||
ts := TS(time.Now().Unix())
|
ts := TS(1234567890)
|
||||||
js, err := json.Marshal(ts)
|
js, err := json.Marshal(ts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@@ -18,7 +47,7 @@ func TestJSONTS(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if ts != ts2 {
|
if ts != ts2 {
|
||||||
t.Fatal(ts2)
|
t.Fatalf("want: %v, got: %v", ts, ts2)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := json.Unmarshal([]byte(`123`), &ts2); err != nil {
|
if err := json.Unmarshal([]byte(`123`), &ts2); err != nil {
|
||||||
|
|||||||
634
pttodoer/Cargo.lock
generated
Normal file
634
pttodoer/Cargo.lock
generated
Normal file
@@ -0,0 +1,634 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "aho-corasick"
|
||||||
|
version = "1.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "android-tzdata"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "android_system_properties"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anstream"
|
||||||
|
version = "0.6.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b"
|
||||||
|
dependencies = [
|
||||||
|
"anstyle",
|
||||||
|
"anstyle-parse",
|
||||||
|
"anstyle-query",
|
||||||
|
"anstyle-wincon",
|
||||||
|
"colorchoice",
|
||||||
|
"is_terminal_polyfill",
|
||||||
|
"utf8parse",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anstyle"
|
||||||
|
version = "1.0.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anstyle-parse"
|
||||||
|
version = "0.2.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4"
|
||||||
|
dependencies = [
|
||||||
|
"utf8parse",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anstyle-query"
|
||||||
|
version = "1.0.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5"
|
||||||
|
dependencies = [
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anstyle-wincon"
|
||||||
|
version = "3.0.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19"
|
||||||
|
dependencies = [
|
||||||
|
"anstyle",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "autocfg"
|
||||||
|
version = "1.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bumpalo"
|
||||||
|
version = "3.16.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cc"
|
||||||
|
version = "1.0.97"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "chrono"
|
||||||
|
version = "0.4.38"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401"
|
||||||
|
dependencies = [
|
||||||
|
"android-tzdata",
|
||||||
|
"iana-time-zone",
|
||||||
|
"js-sys",
|
||||||
|
"num-traits",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"windows-targets",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap"
|
||||||
|
version = "4.5.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0"
|
||||||
|
dependencies = [
|
||||||
|
"clap_builder",
|
||||||
|
"clap_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_builder"
|
||||||
|
version = "4.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4"
|
||||||
|
dependencies = [
|
||||||
|
"anstream",
|
||||||
|
"anstyle",
|
||||||
|
"clap_lex",
|
||||||
|
"strsim",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_derive"
|
||||||
|
version = "4.5.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64"
|
||||||
|
dependencies = [
|
||||||
|
"heck",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_lex"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "colorchoice"
|
||||||
|
version = "1.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "core-foundation-sys"
|
||||||
|
version = "0.8.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "croner"
|
||||||
|
version = "2.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "516aad5374ea0ea75a0f0f4512fb4e7ad46c5eeff9971cb8ebc8fd74f1cd16c1"
|
||||||
|
dependencies = [
|
||||||
|
"chrono",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "equivalent"
|
||||||
|
version = "1.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fuchsia-cprng"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hashbrown"
|
||||||
|
version = "0.14.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "heck"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "iana-time-zone"
|
||||||
|
version = "0.1.60"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141"
|
||||||
|
dependencies = [
|
||||||
|
"android_system_properties",
|
||||||
|
"core-foundation-sys",
|
||||||
|
"iana-time-zone-haiku",
|
||||||
|
"js-sys",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"windows-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "iana-time-zone-haiku"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "indexmap"
|
||||||
|
version = "2.2.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
|
||||||
|
dependencies = [
|
||||||
|
"equivalent",
|
||||||
|
"hashbrown",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "is_terminal_polyfill"
|
||||||
|
version = "1.70.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itoa"
|
||||||
|
version = "1.0.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "js-sys"
|
||||||
|
version = "0.3.69"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d"
|
||||||
|
dependencies = [
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.154"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "log"
|
||||||
|
version = "0.4.21"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memchr"
|
||||||
|
version = "2.7.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-traits"
|
||||||
|
version = "0.2.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "once_cell"
|
||||||
|
version = "1.19.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.81"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pttodoer"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"chrono",
|
||||||
|
"clap",
|
||||||
|
"croner",
|
||||||
|
"regex",
|
||||||
|
"serde",
|
||||||
|
"serde_yaml",
|
||||||
|
"tempdir",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "1.0.36"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand"
|
||||||
|
version = "0.4.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293"
|
||||||
|
dependencies = [
|
||||||
|
"fuchsia-cprng",
|
||||||
|
"libc",
|
||||||
|
"rand_core 0.3.1",
|
||||||
|
"rdrand",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_core"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
|
||||||
|
dependencies = [
|
||||||
|
"rand_core 0.4.2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_core"
|
||||||
|
version = "0.4.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rdrand"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
|
||||||
|
dependencies = [
|
||||||
|
"rand_core 0.3.1",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex"
|
||||||
|
version = "1.10.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c"
|
||||||
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"memchr",
|
||||||
|
"regex-automata",
|
||||||
|
"regex-syntax",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-automata"
|
||||||
|
version = "0.4.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea"
|
||||||
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"memchr",
|
||||||
|
"regex-syntax",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-syntax"
|
||||||
|
version = "0.8.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "remove_dir_all"
|
||||||
|
version = "0.5.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
|
||||||
|
dependencies = [
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ryu"
|
||||||
|
version = "1.0.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde"
|
||||||
|
version = "1.0.202"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395"
|
||||||
|
dependencies = [
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_derive"
|
||||||
|
version = "1.0.202"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_yaml"
|
||||||
|
version = "0.9.34+deprecated"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47"
|
||||||
|
dependencies = [
|
||||||
|
"indexmap",
|
||||||
|
"itoa",
|
||||||
|
"ryu",
|
||||||
|
"serde",
|
||||||
|
"unsafe-libyaml",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "strsim"
|
||||||
|
version = "0.11.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "2.0.61"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tempdir"
|
||||||
|
version = "0.3.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
|
||||||
|
dependencies = [
|
||||||
|
"rand",
|
||||||
|
"remove_dir_all",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-ident"
|
||||||
|
version = "1.0.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unsafe-libyaml"
|
||||||
|
version = "0.2.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "utf8parse"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen"
|
||||||
|
version = "0.2.92"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"wasm-bindgen-macro",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-backend"
|
||||||
|
version = "0.2.92"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da"
|
||||||
|
dependencies = [
|
||||||
|
"bumpalo",
|
||||||
|
"log",
|
||||||
|
"once_cell",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro"
|
||||||
|
version = "0.2.92"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726"
|
||||||
|
dependencies = [
|
||||||
|
"quote",
|
||||||
|
"wasm-bindgen-macro-support",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro-support"
|
||||||
|
version = "0.2.92"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"wasm-bindgen-backend",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-shared"
|
||||||
|
version = "0.2.92"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi"
|
||||||
|
version = "0.3.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||||
|
dependencies = [
|
||||||
|
"winapi-i686-pc-windows-gnu",
|
||||||
|
"winapi-x86_64-pc-windows-gnu",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-i686-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-x86_64-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-core"
|
||||||
|
version = "0.52.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-sys"
|
||||||
|
version = "0.52.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-targets"
|
||||||
|
version = "0.52.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb"
|
||||||
|
dependencies = [
|
||||||
|
"windows_aarch64_gnullvm",
|
||||||
|
"windows_aarch64_msvc",
|
||||||
|
"windows_i686_gnu",
|
||||||
|
"windows_i686_gnullvm",
|
||||||
|
"windows_i686_msvc",
|
||||||
|
"windows_x86_64_gnu",
|
||||||
|
"windows_x86_64_gnullvm",
|
||||||
|
"windows_x86_64_msvc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_gnullvm"
|
||||||
|
version = "0.52.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_msvc"
|
||||||
|
version = "0.52.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_gnu"
|
||||||
|
version = "0.52.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_gnullvm"
|
||||||
|
version = "0.52.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_msvc"
|
||||||
|
version = "0.52.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnu"
|
||||||
|
version = "0.52.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnullvm"
|
||||||
|
version = "0.52.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_msvc"
|
||||||
|
version = "0.52.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
|
||||||
15
pttodoer/Cargo.toml
Normal file
15
pttodoer/Cargo.toml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
[package]
|
||||||
|
name = "pttodoer"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
chrono = "0.4.38"
|
||||||
|
clap = { version = "4.4.8", features = ["derive"] }
|
||||||
|
croner = "2.0.4"
|
||||||
|
regex = "1.10.4"
|
||||||
|
serde = { version = "1.0.202", features = [ "serde_derive" ] }
|
||||||
|
serde_yaml = "0.9.34"
|
||||||
|
tempdir = "0.3.7"
|
||||||
1049
pttodoer/src/main.rs
Normal file
1049
pttodoer/src/main.rs
Normal file
File diff suppressed because it is too large
Load Diff
4
pttodoer/src/testdata/.mvp.yaml.done
vendored
Normal file
4
pttodoer/src/testdata/.mvp.yaml.done
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
- todo: a b and c
|
||||||
|
schedule: '* * * * *'
|
||||||
|
ts: 123
|
||||||
|
- d e f
|
||||||
17
pttodoer/src/testdata/legacy.yaml
vendored
Normal file
17
pttodoer/src/testdata/legacy.yaml
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
todo:
|
||||||
|
- a
|
||||||
|
- todo: b
|
||||||
|
schedule: 2000-01-01
|
||||||
|
scheduled:
|
||||||
|
- c
|
||||||
|
- todo: d
|
||||||
|
schedule: 2000-02-01
|
||||||
|
- todo: e
|
||||||
|
ts: Sun Dec 3 23:29:27 EST 2023
|
||||||
|
schedule: '0 0 1 1 *'
|
||||||
|
- todo: f
|
||||||
|
schedule: 2099-02-02
|
||||||
|
done:
|
||||||
|
- g
|
||||||
|
- todo: h
|
||||||
|
ts: Sun Dec 3 23:29:27 EST 2023
|
||||||
1
pttodoer/src/testdata/mvp.uuid-123-456-xyz.yaml
vendored
Normal file
1
pttodoer/src/testdata/mvp.uuid-123-456-xyz.yaml
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
plaintext
|
||||||
4
pttodoer/src/testdata/mvp.uuid-789-012-abc.yaml
vendored
Normal file
4
pttodoer/src/testdata/mvp.uuid-789-012-abc.yaml
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
todo: todo here
|
||||||
|
schedule: '* * * * *'
|
||||||
|
details: |
|
||||||
|
hello world
|
||||||
2
pttodoer/src/testdata/mvp.yaml
vendored
Normal file
2
pttodoer/src/testdata/mvp.yaml
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
- x
|
||||||
|
- y and z
|
||||||
10
pttodoer/src/testdata/tasks_due_scheduled_done.yaml
vendored
Normal file
10
pttodoer/src/testdata/tasks_due_scheduled_done.yaml
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
- 1do: due
|
||||||
|
schedule: 2006-04-05
|
||||||
|
- 2do: scheduled
|
||||||
|
schedule: 2099-04-05
|
||||||
|
- 3do: repeating scheduled
|
||||||
|
schedule: 0 0 1 1 *
|
||||||
|
ts: 2001-02-03T04:05:06Z
|
||||||
|
- _done:
|
||||||
|
do: done
|
||||||
|
schedule: 2006-04-05
|
||||||
1
pttodoer/src/testdata/taskss.d/file.d/file.yaml
vendored
Normal file
1
pttodoer/src/testdata/taskss.d/file.d/file.yaml
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
- file
|
||||||
1
pttodoer/src/testdata/taskss.d/files.d/a.yaml
vendored
Normal file
1
pttodoer/src/testdata/taskss.d/files.d/a.yaml
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
- a
|
||||||
1
pttodoer/src/testdata/taskss.d/files.d/b.yaml
vendored
Normal file
1
pttodoer/src/testdata/taskss.d/files.d/b.yaml
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
- b
|
||||||
4
pttodoer/src/testdata/taskss.d/single_file.yaml
vendored
Normal file
4
pttodoer/src/testdata/taskss.d/single_file.yaml
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
- todo
|
||||||
|
- do: scheduled
|
||||||
|
schedule: 2099-01-01
|
||||||
|
- _done: any
|
||||||
0
sample.yaml → testdata/sample.yaml
vendored
0
sample.yaml → testdata/sample.yaml
vendored
81
todo.yaml
81
todo.yaml
@@ -1,9 +1,11 @@
|
|||||||
todo:
|
todo:
|
||||||
- todo: when to run scheduled modifier? like, syncthing could have conflicts if I modify only file on remote
|
- when merging, check for complete/incomplete and cross reference todo vs scheduled
|
||||||
details: |
|
vs done
|
||||||
- if it's a web ui hook or somethin, then it'd only have file conflict if I modify without waiting
|
- click on links when dumped via cli
|
||||||
- but thats a step back from current todo solution
|
scheduled: []
|
||||||
|
done:
|
||||||
|
- xactions emails extend ledger,todo-server with pttodo - schedule merge inbox style
|
||||||
|
- xactions emails extend ledger,todo-server with pttodo
|
||||||
- todo: ez edit on many platforms, even offline and mobile
|
- todo: ez edit on many platforms, even offline and mobile
|
||||||
details: |
|
details: |
|
||||||
mobile view + complete method
|
mobile view + complete method
|
||||||
@@ -12,22 +14,69 @@ todo:
|
|||||||
web server access to ops
|
web server access to ops
|
||||||
is a web ui for mobile best solution?
|
is a web ui for mobile best solution?
|
||||||
let git be smart-ish and keep latest? would provide versioning OOTB without touching raw
|
let git be smart-ish and keep latest? would provide versioning OOTB without touching raw
|
||||||
|
- todo: when to run scheduled modifier? like, syncthing could have conflicts if I
|
||||||
done:
|
modify only file on remote
|
||||||
|
details: |
|
||||||
|
- if it's a web ui hook or somethin, then it'd only have file conflict if I modify without waiting
|
||||||
|
- but thats a step back from current todo solution
|
||||||
|
tags: stuffToTry,secondTag
|
||||||
|
- what do about todo-now vs todo vs watch vs later... could do many files and manage
|
||||||
|
outside binary, but search would suck. Good would be vendor lockin, and that's UI
|
||||||
|
problem
|
||||||
|
- merge multi todo files for 'inbox' style with some dedupe (probably best to just
|
||||||
|
do this via calling pttodo-cli from script or somethin) (probably at an off hour
|
||||||
|
so no collisions from live editing)
|
||||||
|
- how to defer a scheduled task?
|
||||||
|
- todo: add tag anti-search, like -tag=-notMe
|
||||||
|
ts: Tue Jan 4 06:56:03 EST 2022
|
||||||
|
- todo: if in todo, then omit ts field
|
||||||
|
ts: Sun Jan 2 20:44:27 EST 2022
|
||||||
|
- todo: merge full files to import from todo-server
|
||||||
|
ts: Sun Jan 2 20:44:27 EST 2022
|
||||||
|
- todo: more schedule formats, like just 2022-01-15, for deferring
|
||||||
|
ts: Sun Jan 2 20:44:27 EST 2022
|
||||||
|
- todo: from todo-server to pttodo format
|
||||||
|
ts: Sun Jan 2 20:44:27 EST 2022
|
||||||
|
- todo: add -tag to search via cli
|
||||||
|
ts: Sun Jan 2 20:44:27 EST 2022
|
||||||
|
- todo: ts to human readable
|
||||||
|
ts: Sun Jan 2 20:44:27 EST 2022
|
||||||
|
- todo: here is my really here is my really here is my really here is my really here
|
||||||
|
is my really here is my really here is my really here is my really here is my
|
||||||
|
really here is my really here is my really here is my really here is my really
|
||||||
|
here is my really here is my really long string
|
||||||
|
ts: Sun Jan 2 20:44:27 EST 2022
|
||||||
|
- todo: vim doesnt source vimrc, so stuff like tab width and tab characters, also
|
||||||
|
syntax highlight :(
|
||||||
|
ts: Sun Jan 2 20:44:27 EST 2022
|
||||||
- todo: crontab -e style editing to ensure good syntax
|
- todo: crontab -e style editing to ensure good syntax
|
||||||
|
ts: Sun Jan 2 20:44:27 EST 2022
|
||||||
- todo: YAML based todo
|
- todo: YAML based todo
|
||||||
details:
|
details: because goddamnit a year of this shit isn't significant on disk or in RAM
|
||||||
because goddamnit a year of this shit
|
for vim
|
||||||
isn't significant on disk or in RAM for vim
|
ts: Fri Dec 31 22:33:12 EST 2021
|
||||||
- todo: yaml based todo for plaintext
|
- todo: yaml based todo for plaintext
|
||||||
details: a year isnt even a mb
|
details: a year isnt even a mb
|
||||||
- ez edit, start on many platforms
|
ts: Fri Dec 31 22:33:12 EST 2021
|
||||||
- defer
|
- todo: ez edit, start on many platforms
|
||||||
- schedule
|
ts: Sun Jan 2 20:44:27 EST 2022
|
||||||
- looping
|
- todo: defer
|
||||||
- details
|
ts: Sun Jan 2 20:44:27 EST 2022
|
||||||
|
- todo: schedule
|
||||||
|
ts: Sun Jan 2 20:44:27 EST 2022
|
||||||
|
- todo: looping
|
||||||
|
ts: Sun Jan 2 20:44:27 EST 2022
|
||||||
|
- todo: details
|
||||||
|
ts: Sun Jan 2 20:44:27 EST 2022
|
||||||
- todo: let UI be UI for whatever platform
|
- todo: let UI be UI for whatever platform
|
||||||
- tags
|
ts: Sun Jan 2 20:44:27 EST 2022
|
||||||
|
- todo: tags
|
||||||
|
ts: Sun Jan 2 20:44:27 EST 2022
|
||||||
- todo: sub tasks
|
- todo: sub tasks
|
||||||
subtasks:
|
subtasks:
|
||||||
- a
|
- a
|
||||||
|
ts: Fri Dec 31 22:33:12 EST 2021
|
||||||
|
- todo: crap losing on a bad edit hurts
|
||||||
|
details: |
|
||||||
|
?
|
||||||
|
ts: Fri Dec 31 22:37:58 EST 2021
|
||||||
|
|||||||
Reference in New Issue
Block a user