diff --git a/cmd/xfer/from_todo_server_to_pttodo.sh b/cmd/xfer/from_todo_server_to_pttodo.sh new file mode 100644 index 0000000..38831e3 --- /dev/null +++ b/cmd/xfer/from_todo_server_to_pttodo.sh @@ -0,0 +1,49 @@ +#! /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"}" + +main() { + set -e + set -o pipefail + COMPL=1 LOOPING=1 fetch_tasks_in_list | format_tasks_in_list + return 0 + local tasks_in_todo="$(fetch_tasks_in_list | format_tasks_in_list)" + local schedule_tasks_in_flight="$(COMPL=1 LOOPING=1 fetch_tasks_in_list | format_tasks_in_list)" + echo "{\"todo\": $tasks_in_todo, \"scheduled\": $schedule_tasks_in_flight, \"done\": []}" | yq -P eval - +} + +format_tasks_in_list() { + jq -c .list[] | while read -r line; do + echo "$line" \ + | jq '{ + todo: .title, + details:.note, + ts: (if .compl == 1 then (.dateCompleted | strptime("%d %b %Y %I:%M %p") | mktime) else .dateEditedInt end), + subtasks: [], + tags: .tags, + schedule: (if (.cron != "") then (.cron) else (.loop) end) + }' \ + | jq -c . + done | jq -sc | yq -P eval - | grep -v -E ' (""|\[]|0s)$' | yq -j eval - | jq -c . +} + +fetch_tasks_in_list() { + local csv_headers="$TODO_SERVER_HEADERS" + local headers=() + while [ "$csv_headers" != "" ]; do + header="${csv_headers%%,*}" + headers+=("-H" "${header%%:*}: ${header#*:}") + if echo "$csv_headers" | grep -q ,; then + csv_headers="${csv_headers#*,}" + else + csv_headers="" + fi + done + curl -sS "${headers[@]}" "$TODO_SERVER_URL/ajax.php?loadTasks=&list=$TODO_SERVER_LIST&compl=${COMPL:-0}&looping=${LOOPING:-0}" +} + +if [ "$0" == "$BASH_SOURCE" ]; then + main "$@" +fi diff --git a/todo.yaml b/todo.yaml index edd60f6..c3daacc 100644 --- a/todo.yaml +++ b/todo.yaml @@ -1,4 +1,5 @@ todo: +- merge multi todo files for 'inbox' style - what do about todo-now vs todo vs watch vs later... - add tag anti-search, like -tag=-notMe - todo: when to run scheduled modifier? like, syncthing could have conflicts if I @@ -19,6 +20,7 @@ todo: let git be smart-ish and keep latest? would provide versioning OOTB without touching raw scheduled: [] done: +- 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