From 81fdad4f3662d4c0fbb2968f6daa1a6cedfcc8bd Mon Sep 17 00:00:00 2001 From: doczi-dominik Date: Sun, 12 May 2019 00:09:25 +0200 Subject: [PATCH 1/3] Added ability to remove/finish multiple tasks --- t.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/t.py b/t.py index b2594f8..af97219 100755 --- a/t.py +++ b/t.py @@ -7,6 +7,7 @@ import os, re, sys, hashlib from operator import itemgetter from optparse import OptionParser, OptionGroup +from re import split as re_split class InvalidTaskfile(Exception): @@ -195,27 +196,28 @@ def edit_task(self, prefix, text): task['text'] = text task['id'] = _hash(text) - def finish_task(self, prefix): - """Mark the task with the given prefix as finished. + def finish_task(self, prefix_list): + """Mark tasks with the given prefix as finished. If more than one task matches the prefix an AmbiguousPrefix exception will be raised, if no tasks match it an UnknownPrefix exception will be raised. """ - task = self.tasks.pop(self[prefix]['id']) - self.done[task['id']] = task + for prefix in re_split(",", prefix_list): + task = self.tasks.pop(self[prefix]['id']) + self.done[task['id']] = task - def remove_task(self, prefix): - """Remove the task from tasks list. + def remove_task(self, prefix_list): + """Remove tasks from tasks list. If more than one task matches the prefix an AmbiguousPrefix exception will be raised, if no tasks match it an UnknownPrefix exception will be raised. """ - self.tasks.pop(self[prefix]['id']) - + for prefix in re_split(",", prefix_list): + self.tasks.pop(self[prefix]['id']) def print_list(self, kind='tasks', verbose=False, quiet=False, grep=''): """Print out a nicely formatted list of unfinished tasks.""" From e954ea7f6e01a7364f3baa398ad20c6410d8470f Mon Sep 17 00:00:00 2001 From: doczi-dominik Date: Sun, 12 May 2019 00:25:19 +0200 Subject: [PATCH 2/3] Modified README for multiple finishes/deletes --- README.markdown | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.markdown b/README.markdown index ae8bf41..c8caa66 100644 --- a/README.markdown +++ b/README.markdown @@ -105,6 +105,7 @@ To add a task, use `t [task description]`: $ t Clean the apartment. $ t Write chapter 10 of the novel. $ t Buy more beer. + $ t Write some code $ ### List Your Tasks @@ -115,6 +116,7 @@ Listing your tasks is even easier -- just use `t`: 9 - Buy more beer. 30 - Clean the apartment. 31 - Write chapter 10 of the novel. + e - Write some code $ `t` will list all of your unfinished tasks and their IDs. @@ -127,6 +129,10 @@ After you're done with something, use `t -f ID` to finish it: $ t 9 - Buy more beer. 30 - Clean the apartment. + e - Write some code + $ t -f 9,30 + $ t + e - Write some code $ ### Edit a Task From 39d5da5a871e3b2a925e743186f0222501417870 Mon Sep 17 00:00:00 2001 From: doczi-dominik Date: Sun, 12 May 2019 00:26:10 +0200 Subject: [PATCH 3/3] Modified --help text for multiple finishes/deletes --- t.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t.py b/t.py index af97219..093de6a 100755 --- a/t.py +++ b/t.py @@ -264,9 +264,9 @@ def _build_parser(): actions.add_option("-e", "--edit", dest="edit", default="", help="edit TASK to contain TEXT", metavar="TASK") actions.add_option("-f", "--finish", dest="finish", - help="mark TASK as finished", metavar="TASK") + help="mark TASK (t -f ID) or TASKS (t -f ID,ID) as finished", metavar="TASK") actions.add_option("-r", "--remove", dest="remove", - help="Remove TASK from list", metavar="TASK") + help="Remove TASK (t -r ID) or TASKS (t -r ID,ID) from list", metavar="TASK") parser.add_option_group(actions) config = OptionGroup(parser, "Configuration Options")