summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rwxr-xr-xcalendar-cli.py15
-rwxr-xr-xtests/script_test.sh27
3 files changed, 41 insertions, 3 deletions
diff --git a/README.md b/README.md
index 50c7ced..efadf2e 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
calendar-cli
============
-Simple command-line CalDav client, for adding and browsing calendar items, todo list items, etc
+Simple command-line CalDav client, for adding and browsing calendar items, todo list items, etc. As of version 0.11 it's even becoming a full-fledged task management tool.
There is a "competing" project at https://github.com/geier/khal - you may want to check it out - it's more mature but probably more complex. It's using a "vsyncdir" backend - if I've understood it correctly, that involves building a local copy of the calendar. The philosophy behind calendar-cli is slightly different, calendar-cli is supposed to be a simple cli-based caldav+ical client. No synchronization, no local storage.
diff --git a/calendar-cli.py b/calendar-cli.py
index 636e3bc..8380f2f 100755
--- a/calendar-cli.py
+++ b/calendar-cli.py
@@ -377,6 +377,20 @@ def todo_select(caldav_conn, args):
for attr in vtodo_txt_one + vtodo_txt_many: ## TODO: now we have _exact_ match on items in the the array attributes, and substring match on items that cannot be duplicated. Does that make sense? Probably not.
if getattr(args, attr):
tasks = [x for x in tasks if hasattr(x.instance.vtodo, attr) and getattr(args, attr) in getattr(x.instance.vtodo, attr).value]
+ if args.hide_parents:
+ tasks_by_uid = {}
+ for task in tasks:
+ tasks_by_uid[task.instance.vtodo.uid.value] = task
+ for task in tasks:
+ if hasattr(task.instance.vtodo, 'related_to'):
+ uid = task.instance.vtodo.uid.value
+ rel_uid = task.instance.vtodo.related_to.value
+ rel_type = task.instance.vtodo.related_to.params.get('RELTYPE', 'PARENT')
+ if rel_type == 'CHILD' and rel_uid in tasks_by_uid and uid in tasks_by_uid:
+ del tasks_by_uid[uid]
+ if rel_type == 'PARENT' and rel_uid in tasks_by_uid:
+ del tasks_by_uid[rel_uid]
+ tasks = [x for x in tasks if x.instance.vtodo.uid.value in tasks_by_uid]
if args.top+args.limit:
tasks = tasks[args.offset+args.offsetn:args.top+args.limit+args.offset+args.offsetn]
elif args.offset+args.offsetn:
@@ -581,6 +595,7 @@ def main():
todo_parser.add_argument('--offsetn', type=int, default=0)
todo_parser.add_argument('--limit', type=int, default=0)
todo_parser.add_argument('--todo-uid')
+ todo_parser.add_argument('--hide-parents', help='Hide the parent if you need to work on children tasks first (parent task depends on children tasks to be done first)', action='store_true')
for attr in vtodo_txt_one + vtodo_txt_many:
todo_parser.add_argument('--'+attr, help="for filtering tasks")
diff --git a/tests/script_test.sh b/tests/script_test.sh
index 375acdb..1636478 100755
--- a/tests/script_test.sh
+++ b/tests/script_test.sh
@@ -70,7 +70,7 @@ calendar_cli todo --categories scripttest list
[ $(echo "$output" | wc -l) == 1 ] && echo "## OK: found the todo item we just added and nothing more"
echo "## Editing the task"
-calendar_cli todo --categories scripttest edit --set-comment "editing" --add-categories "scripttest2"
+calendar_cli todo --categories scripttest edit --set-summary "editing" --add-categories "scripttest2"
echo "## Verifying that the edits got through"
calendar_cli todo --categories scripttest list
@@ -84,6 +84,29 @@ echo "## Complete the task"
calendar_cli todo --categories scripttest complete
calendar_cli todo --categories scripttest list
[ -z "$output" ] && echo "## OK: todo-item is done"
-calendar_cli todo --todo-uid $todouid1 delete
+calendar_cli todo --todo-uid $uidtodo1 delete
+
+## parent-child relationships
+echo "## Going to add three todo-items with children/parent relationships"
+calendar_cli todo add --set-categories scripttest "this is a grandparent"
+uidtodo2=$(echo $output | perl -ne '/uid=(.*)$/ && print $1')
+calendar_cli todo --categories=scripttest add --set-categories scripttest --is-child "this is a parent and a child"
+uidtodo3=$(echo $output | perl -ne '/uid=(.*)$/ && print $1')
+calendar_cli todo --categories=scripttest add --set-categories scripttest --is-child "this task has two parents"
+uidtodo4=$(echo $output | perl -ne '/uid=(.*)$/ && print $1')
+calendar_cli todo --categories scripttest list
+[ $(echo "$output" | wc -l) == 3 ] && echo "## OK: found three tasks"
+calendar_cli todo --hide-parents --categories scripttest list
+[ $(echo "$output" | wc -l) == 1 ] && echo "## OK: found only one task now"
+echo "## Going to complete the children task"
+calendar_cli todo --hide-parents --categories scripttest complete
+calendar_cli todo --hide-parents --categories scripttest list
+[ $(echo "$output" | wc -l) == 1 ] && echo "## OK: found only one task now"
+calendar_cli todo --hide-parents --categories scripttest complete
+calendar_cli todo --hide-parents --categories scripttest list
+[ $(echo "$output" | wc -l) == 1 ] && echo "## OK: found only one task now"
+calendar_cli todo --hide-parents --categories scripttest complete
+calendar_cli todo --hide-parents --categories scripttest list
+[ -z "$output" ] && echo "## OK: found no tasks now"
echo "## all tests completed"