Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ccdd2615c4 | ||
|
|
0241f2d76c | ||
|
|
fa812a16ee | ||
|
|
cf3b233a11 | ||
|
|
64868bdc0b | ||
|
|
1b1724bea7 | ||
|
|
f4968d1d1b | ||
|
|
6203ced79b | ||
|
|
4d171d10d0 | ||
|
|
8ad2ca9345 | ||
|
|
bc0bb05fb6 | ||
|
|
22dc04341c |
@@ -38,7 +38,7 @@ func _main() error {
|
|||||||
filepath := flag.String("f", defaultFilepath, "($PTTODO_FILE) path to yaml file")
|
filepath := flag.String("f", defaultFilepath, "($PTTODO_FILE) path to yaml file")
|
||||||
filepathToMergeIn := flag.String("g", "", "path to yaml file to merge into -f")
|
filepathToMergeIn := flag.String("g", "", "path to yaml file to merge into -f")
|
||||||
root := flag.String("root", DUMP_TODO, "path to pretty print ("+fmt.Sprint([]string{DUMP_ALL, DUMP_TODO, DUMP_SCHEDULED, DUMP_DONE})+")")
|
root := flag.String("root", DUMP_TODO, "path to pretty print ("+fmt.Sprint([]string{DUMP_ALL, DUMP_TODO, DUMP_SCHEDULED, DUMP_DONE})+")")
|
||||||
tags := flag.String("tags", "", "csv of all tags to find")
|
tags := flag.String("tags", "", "csv of all tags to find, -tag to invert")
|
||||||
search := flag.String("search", "", "fts case insensitive")
|
search := flag.String("search", "", "fts case insensitive")
|
||||||
e := flag.Bool("e", false, "edit file")
|
e := flag.Bool("e", false, "edit file")
|
||||||
dry := flag.Bool("dry", false, "dry run")
|
dry := flag.Bool("dry", false, "dry run")
|
||||||
@@ -79,7 +79,10 @@ func verifyRoot(root pttodo.Root) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func verifyFile(path string) error {
|
func verifyFile(path string) error {
|
||||||
return dump(true, io.Discard, path, nil, "", DUMP_ALL)
|
if err := dump(true, io.Discard, path, nil, "", DUMP_ALL); err != nil {
|
||||||
|
return fmt.Errorf("failed verifying file %s: %w", path, err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func edit(dry bool, filepath string) error {
|
func edit(dry bool, filepath string) error {
|
||||||
@@ -143,6 +146,20 @@ func edit(dry bool, filepath string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
verify := func() error {
|
verify := func() error {
|
||||||
|
for {
|
||||||
|
err := verifyFile(tempFile)
|
||||||
|
if err == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
log.Printf("%v, press <Enter> to resume editing", err)
|
||||||
|
b := make([]byte, 1)
|
||||||
|
if _, err := os.Stdin.Read(b); err != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if err := vi(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
return verifyFile(tempFile)
|
return verifyFile(tempFile)
|
||||||
}
|
}
|
||||||
save := func() error {
|
save := func() error {
|
||||||
@@ -255,11 +272,14 @@ func dump(dry bool, writer io.Writer, filepath string, tags []string, search, ro
|
|||||||
if len(tags) > 0 {
|
if len(tags) > 0 {
|
||||||
result := make([]pttodo.Todo, 0, len(todos))
|
result := make([]pttodo.Todo, 0, len(todos))
|
||||||
for _, todo := range todos {
|
for _, todo := range todos {
|
||||||
want := len(todo.Tags) > 0
|
skip := false
|
||||||
for _, tag := range tags {
|
for _, tag := range tags {
|
||||||
want = want && strings.Contains(todo.Tags, tag)
|
positiveTag := strings.TrimLeft(tag, "-")
|
||||||
|
hasTag := strings.Contains(todo.Tags, positiveTag)
|
||||||
|
wantToHaveTag := !strings.HasPrefix(tag, "-")
|
||||||
|
skip = skip || !(hasTag == wantToHaveTag)
|
||||||
}
|
}
|
||||||
if want {
|
if !skip {
|
||||||
result = append(result, todo)
|
result = append(result, todo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
21
cmd/xfer/all_from_todo_server_to_pttodo.sh
Normal file
21
cmd/xfer/all_from_todo_server_to_pttodo.sh
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
main() {
|
||||||
|
cd "$(dirname "$BASH_SOURCE")"
|
||||||
|
source ./from_todo_server_to_pttodo.sh
|
||||||
|
type from_todo_server_to_pttodo_main
|
||||||
|
list_lists | jq .list[] | jq -c . | while read -r line; do
|
||||||
|
local name="$(echo "$line" | jq -r .name | sed 's/^Today$/todo/g' | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g')"
|
||||||
|
local id="$(echo "$line" | jq -r .id)"
|
||||||
|
echo $name, $id
|
||||||
|
TODO_SERVER_LIST="$id" from_todo_server_to_pttodo_main > ./$name.yaml
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
list_lists() {
|
||||||
|
todo_server_curl "$TODO_SERVER_URL/ajax.php?loadLists=&rnd=0.9900282499544026"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$0" == "$BASH_SOURCE" ]; then
|
||||||
|
main "$@"
|
||||||
|
fi
|
||||||
@@ -1,10 +1,14 @@
|
|||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
TODO_SERVER_URL="${TODO_SERVER_URL:-"https://todo-server.remote.blapointe.com"}"
|
export TODO_SERVER_URL="${TODO_SERVER_URL:-"https://todo-server.remote.blapointe.com"}"
|
||||||
TODO_SERVER_HEADERS="${TODO_SERVER_HEADERS:-"Cookie: BOAuthZ=$TODO_SERVER_BOAUTHZ"}"
|
export TODO_SERVER_HEADERS="${TODO_SERVER_HEADERS:-"Cookie: BOAuthZ=$TODO_SERVER_BOAUTHZ"}"
|
||||||
TODO_SERVER_LIST="${TODO_SERVER_LIST:-"2548023766"}"
|
export TODO_SERVER_LIST="${TODO_SERVER_LIST:-"2548023766"}"
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
from_todo_server_to_pttodo_main "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
from_todo_server_to_pttodo_main() {
|
||||||
set -e
|
set -e
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
local tasks_in_todo="$(fetch_tasks_in_list | format_tasks_in_list)"
|
local tasks_in_todo="$(fetch_tasks_in_list | format_tasks_in_list)"
|
||||||
@@ -28,6 +32,10 @@ format_tasks_in_list() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fetch_tasks_in_list() {
|
fetch_tasks_in_list() {
|
||||||
|
todo_server_curl "$TODO_SERVER_URL/ajax.php?loadTasks=&list=$TODO_SERVER_LIST&compl=${COMPL:-0}&looping=${LOOPING:-0}"
|
||||||
|
}
|
||||||
|
|
||||||
|
todo_server_curl() {
|
||||||
local csv_headers="$TODO_SERVER_HEADERS"
|
local csv_headers="$TODO_SERVER_HEADERS"
|
||||||
local headers=()
|
local headers=()
|
||||||
while [ "$csv_headers" != "" ]; do
|
while [ "$csv_headers" != "" ]; do
|
||||||
@@ -39,7 +47,7 @@ fetch_tasks_in_list() {
|
|||||||
csv_headers=""
|
csv_headers=""
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
curl -sS "${headers[@]}" "$TODO_SERVER_URL/ajax.php?loadTasks=&list=$TODO_SERVER_LIST&compl=${COMPL:-0}&looping=${LOOPING:-0}"
|
curl -sS "${headers[@]}" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$0" == "$BASH_SOURCE" ]; then
|
if [ "$0" == "$BASH_SOURCE" ]; then
|
||||||
|
|||||||
@@ -36,3 +36,17 @@ func (root *Root) MergeIn(root2 Root) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -145,3 +146,28 @@ todo:
|
|||||||
t.Fatalf("want \n\t%+v, got \n\t%+v", rootWant, root0)
|
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)
|
||||||
|
}
|
||||||
|
if strings.TrimSpace(string(got)) != strings.TrimSpace(`
|
||||||
|
todo:
|
||||||
|
- todo
|
||||||
|
scheduled:
|
||||||
|
- todo: sched
|
||||||
|
schedule: "2099-01-01"
|
||||||
|
ts: Wed Dec 31 19:00:02 EST 1969
|
||||||
|
done:
|
||||||
|
- todo: done
|
||||||
|
ts: Wed Dec 31 19:00:03 EST 1969
|
||||||
|
`) {
|
||||||
|
t.Fatal(string(got))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,11 +7,12 @@ import (
|
|||||||
|
|
||||||
type Todo struct {
|
type Todo struct {
|
||||||
Todo string
|
Todo string
|
||||||
TS TS
|
|
||||||
Details string `yaml:",omitempty"`
|
Details string `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 (todo Todo) Triggered() bool {
|
func (todo Todo) Triggered() bool {
|
||||||
@@ -21,6 +22,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
|
||||||
}
|
}
|
||||||
|
|||||||
79
todo.yaml
79
todo.yaml
@@ -1,18 +1,21 @@
|
|||||||
todo:
|
todo:
|
||||||
- merge multi todo files for 'inbox' style with some dedupe
|
- when merging, check for complete/incomplete and cross reference todo vs scheduled
|
||||||
|
vs done
|
||||||
|
- how to defer a scheduled task?
|
||||||
|
- 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)
|
||||||
- click on links when dumped via cli
|
- click on links when dumped via cli
|
||||||
- what do about todo-now vs todo vs watch vs later... could do many files and manage
|
- 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
|
outside binary, but search would suck. Good would be vendor lockin, and that's UI
|
||||||
- add tag anti-search, like -tag=-notMe
|
problem
|
||||||
- todo: when to run scheduled modifier? like, syncthing could have conflicts if I
|
- todo: when to run scheduled modifier? like, syncthing could have conflicts if I
|
||||||
modify only file on remote
|
modify only file on remote
|
||||||
ts: Fri Dec 31 22:33:12 EST 2021
|
|
||||||
details: |
|
details: |
|
||||||
- if it's a web ui hook or somethin, then it'd only have file conflict if I modify without waiting
|
- 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
|
- but thats a step back from current todo solution
|
||||||
tags: stuffToTry,secondTag
|
tags: stuffToTry,secondTag
|
||||||
- todo: ez edit on many platforms, even offline and mobile
|
- todo: ez edit on many platforms, even offline and mobile
|
||||||
ts: Fri Dec 31 22:33:12 EST 2021
|
|
||||||
details: |
|
details: |
|
||||||
mobile view + complete method
|
mobile view + complete method
|
||||||
collab editing of file prob resolves mobile and other stuff...
|
collab editing of file prob resolves mobile and other stuff...
|
||||||
@@ -20,38 +23,60 @@ 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
|
||||||
|
- xactions emails extend ledger,todo-server with pttodo
|
||||||
|
- xactions emails extend ledger,todo-server with pttodo - schedule merge inbox style
|
||||||
scheduled: []
|
scheduled: []
|
||||||
done:
|
done:
|
||||||
- more schedule formats, like just 2022-01-15, for deferring
|
- todo: add tag anti-search, like -tag=-notMe
|
||||||
- from todo-server to pttodo format
|
ts: Tue Jan 4 06:56:03 EST 2022
|
||||||
- add -tag to search via cli
|
- todo: if in todo, then omit ts field
|
||||||
- ts to human readable
|
ts: Sun Jan 2 20:44:27 EST 2022
|
||||||
- here is my really here is my really here is my really here is my really here is
|
- todo: merge full files to import from todo-server
|
||||||
my really here is my really here is my really here is my really here is my really
|
ts: Sun Jan 2 20:44:27 EST 2022
|
||||||
here is my really here is my really here is my really here is my really here is
|
- todo: more schedule formats, like just 2022-01-15, for deferring
|
||||||
my really here is my really long string
|
ts: Sun Jan 2 20:44:27 EST 2022
|
||||||
- vim doesnt source vimrc, so stuff like tab width and tab characters, also syntax
|
- todo: from todo-server to pttodo format
|
||||||
highlight :(
|
ts: Sun Jan 2 20:44:27 EST 2022
|
||||||
- crontab -e style editing to ensure good syntax
|
- 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
|
||||||
|
ts: Sun Jan 2 20:44:27 EST 2022
|
||||||
- todo: YAML based todo
|
- todo: YAML based todo
|
||||||
ts: Fri Dec 31 22:33:12 EST 2021
|
|
||||||
details: because goddamnit a year of this shit isn't significant on disk or in RAM
|
details: because goddamnit a year of this shit isn't significant on disk or in RAM
|
||||||
for vim
|
for vim
|
||||||
|
ts: Fri Dec 31 22:33:12 EST 2021
|
||||||
- todo: yaml based todo for plaintext
|
- todo: yaml based todo for plaintext
|
||||||
ts: Fri Dec 31 22:33:12 EST 2021
|
|
||||||
details: a year isnt even a mb
|
details: a year isnt even a mb
|
||||||
- ez edit, start on many platforms
|
|
||||||
- defer
|
|
||||||
- schedule
|
|
||||||
- looping
|
|
||||||
- details
|
|
||||||
- let UI be UI for whatever platform
|
|
||||||
- tags
|
|
||||||
- todo: sub tasks
|
|
||||||
ts: Fri Dec 31 22:33:12 EST 2021
|
ts: Fri Dec 31 22:33:12 EST 2021
|
||||||
|
- todo: ez edit, start on many platforms
|
||||||
|
ts: Sun Jan 2 20:44:27 EST 2022
|
||||||
|
- todo: defer
|
||||||
|
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
|
||||||
|
ts: Sun Jan 2 20:44:27 EST 2022
|
||||||
|
- todo: tags
|
||||||
|
ts: Sun Jan 2 20:44:27 EST 2022
|
||||||
|
- todo: sub tasks
|
||||||
subtasks:
|
subtasks:
|
||||||
- a
|
- a
|
||||||
|
ts: Fri Dec 31 22:33:12 EST 2021
|
||||||
- todo: crap losing on a bad edit hurts
|
- todo: crap losing on a bad edit hurts
|
||||||
ts: Fri Dec 31 22:37:58 EST 2021
|
|
||||||
details: |
|
details: |
|
||||||
?
|
?
|
||||||
|
ts: Fri Dec 31 22:37:58 EST 2021
|
||||||
|
|||||||
Reference in New Issue
Block a user