12 Commits

Author SHA1 Message Date
Bel LaPointe
ccdd2615c4 instead of trashing editing file in cli, write err msg and re-edit 2022-01-04 12:37:35 -05:00
Bel LaPointe
0241f2d76c err msg 2022-01-04 12:33:39 -05:00
Bel LaPointe
fa812a16ee fix checking hastags and nothas tags 2022-01-04 08:56:19 -05:00
Bel LaPointe
cf3b233a11 add anti tag search 2022-01-04 07:01:35 -05:00
Bel LaPointe
64868bdc0b create script to scrape list of lists and scrape aech into a yaml 2022-01-03 16:36:59 -05:00
Bel LaPointe
1b1724bea7 update todo with no more ts in todo section 2022-01-02 20:45:17 -05:00
Bel LaPointe
f4968d1d1b update todo 2022-01-02 20:44:23 -05:00
Bel LaPointe
6203ced79b root does not marshal TSs on todos, always on schedules, dones. Test. 2022-01-02 20:44:04 -05:00
Bel LaPointe
4d171d10d0 only write TS on a todo if writeTS is set 2022-01-02 20:37:40 -05:00
Bel LaPointe
8ad2ca9345 new todo 2022-01-02 20:32:16 -05:00
Bel LaPointe
bc0bb05fb6 update todo 2022-01-02 20:31:09 -05:00
Bel LaPointe
22dc04341c update todo.yaml 2022-01-02 20:17:32 -05:00
7 changed files with 157 additions and 37 deletions

View File

@@ -38,7 +38,7 @@ func _main() error {
filepath := flag.String("f", defaultFilepath, "($PTTODO_FILE) path to yaml file")
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})+")")
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")
e := flag.Bool("e", false, "edit file")
dry := flag.Bool("dry", false, "dry run")
@@ -79,7 +79,10 @@ func verifyRoot(root pttodo.Root) 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 {
@@ -143,6 +146,20 @@ func edit(dry bool, filepath string) error {
return nil
}
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)
}
save := func() error {
@@ -255,11 +272,14 @@ func dump(dry bool, writer io.Writer, filepath string, tags []string, search, ro
if len(tags) > 0 {
result := make([]pttodo.Todo, 0, len(todos))
for _, todo := range todos {
want := len(todo.Tags) > 0
skip := false
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)
}
}

View 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

View File

@@ -1,10 +1,14 @@
#! /bin/bash
TODO_SERVER_URL="${TODO_SERVER_URL:-"https://todo-server.remote.blapointe.com"}"
TODO_SERVER_HEADERS="${TODO_SERVER_HEADERS:-"Cookie: BOAuthZ=$TODO_SERVER_BOAUTHZ"}"
TODO_SERVER_LIST="${TODO_SERVER_LIST:-"2548023766"}"
export TODO_SERVER_URL="${TODO_SERVER_URL:-"https://todo-server.remote.blapointe.com"}"
export TODO_SERVER_HEADERS="${TODO_SERVER_HEADERS:-"Cookie: BOAuthZ=$TODO_SERVER_BOAUTHZ"}"
export TODO_SERVER_LIST="${TODO_SERVER_LIST:-"2548023766"}"
main() {
from_todo_server_to_pttodo_main "$@"
}
from_todo_server_to_pttodo_main() {
set -e
set -o pipefail
local tasks_in_todo="$(fetch_tasks_in_list | format_tasks_in_list)"
@@ -28,6 +32,10 @@ format_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 headers=()
while [ "$csv_headers" != "" ]; do
@@ -39,7 +47,7 @@ fetch_tasks_in_list() {
csv_headers=""
fi
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

View File

@@ -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
}

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"strconv"
"strings"
"testing"
"time"
@@ -145,3 +146,28 @@ todo:
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))
}
}

View File

@@ -7,11 +7,12 @@ import (
type Todo struct {
Todo string
TS TS
Details string `yaml:",omitempty"`
Schedule Schedule `yaml:",omitempty"`
Tags string `yaml:",omitempty"`
Subtasks []Todo `yaml:",omitempty"`
TS TS `yaml:",omitempty"`
writeTS bool
}
func (todo Todo) Triggered() bool {
@@ -21,6 +22,11 @@ func (todo Todo) Triggered() bool {
}
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}) {
return todo.Todo, nil
}

View File

@@ -1,18 +1,21 @@
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
- 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
- add tag anti-search, like -tag=-notMe
outside binary, but search would suck. Good would be vendor lockin, and that's UI
problem
- todo: when to run scheduled modifier? like, syncthing could have conflicts if I
modify only file on remote
ts: Fri Dec 31 22:33:12 EST 2021
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
- todo: ez edit on many platforms, even offline and mobile
ts: Fri Dec 31 22:33:12 EST 2021
details: |
mobile view + complete method
collab editing of file prob resolves mobile and other stuff...
@@ -20,38 +23,60 @@ todo:
web server access to ops
is a web ui for mobile best solution?
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: []
done:
- more schedule formats, like just 2022-01-15, for deferring
- from todo-server to pttodo format
- add -tag to search via cli
- ts to human readable
- 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
- vim doesnt source vimrc, so stuff like tab width and tab characters, also syntax
highlight :(
- crontab -e style editing to ensure good syntax
- 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
ts: Sun Jan 2 20:44:27 EST 2022
- 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
for vim
ts: Fri Dec 31 22:33:12 EST 2021
- todo: yaml based todo for plaintext
ts: Fri Dec 31 22:33:12 EST 2021
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
- 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:
- a
ts: Fri Dec 31 22:33:12 EST 2021
- todo: crap losing on a bad edit hurts
ts: Fri Dec 31 22:37:58 EST 2021
details: |
?
ts: Fri Dec 31 22:37:58 EST 2021