diff options
author | Tobias Brox <t@tobixen.no> | 2015-05-11 01:15:25 +0200 |
---|---|---|
committer | Tobias Brox <t@tobixen.no> | 2015-05-11 01:15:25 +0200 |
commit | f5ab7241c63c04ea53b569d8680e90e3fe8cb432 (patch) | |
tree | 860a9d2fd283495234809bcbd692a83abf570993 | |
parent | aa80c142709f8c64552311c902b1487f90db7e46 (diff) | |
download | calendar-cli-f5ab7241c63c04ea53b569d8680e90e3fe8cb432.zip |
added support for --hide-children
-rwxr-xr-x | calendar-cli.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/calendar-cli.py b/calendar-cli.py index e9e6074..508b886 100755 --- a/calendar-cli.py +++ b/calendar-cli.py @@ -377,7 +377,7 @@ 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: + if args.hide_parents or args.hide_children: tasks_by_uid = {} for task in tasks: tasks_by_uid[task.instance.vtodo.uid.value] = task @@ -386,9 +386,11 @@ def todo_select(caldav_conn, args): 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: + if ((rel_type == 'CHILD' and args.hide_parents) or (rel_type == 'PARENT' and args.hide_children)) 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: + if ((rel_type == 'PARENT' and args.hide_parents) or (rel_type == 'CHILD' and args.hide_children)) 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: @@ -596,6 +598,7 @@ def main(): 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') + todo_parser.add_argument('--hide-children', 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") |