summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2014-12-17 00:24:25 +0100
committerJohannes Löthberg <johannes@kyriasis.com>2014-12-17 00:24:25 +0100
commitb9f5e1d99799656422cd65f8c06b00ebd21ea1af (patch)
tree640b9033012df11271004b0828bb809d891d891f
parent194ef093bbffaab5fa8215cd8262c4a9c5de1335 (diff)
downloadtodo-b9f5e1d99799656422cd65f8c06b00ebd21ea1af.tar.xz
todo: split first line out into own function
-rwxr-xr-xtodo17
1 files changed, 12 insertions, 5 deletions
diff --git a/todo b/todo
index eaecf64..a5f97fd 100755
--- a/todo
+++ b/todo
@@ -96,6 +96,17 @@ def format_priority(priority):
else:
return text
+def first_line(entry_id, entry):
+ line = '\n#{:3}'.format(entry_id)
+ if 'priority' in entry:
+ priority = entry['priority']
+ line += '{} '.format(format_priority(priority))
+
+ if 'date' in entry:
+ line += '{} '.format(entry['date'])
+
+ return line
+
def main():
arguments = docopt(__doc__, version='todo 0.0.1.alpha')
config = parse_args(arguments)
@@ -110,11 +121,7 @@ def main():
for t_id in todo_dict:
task = todo_dict[t_id]
- output = "{}. ".format(t_id)
- if 'priority' in task:
- output += '{} '.format(format_priority(task['priority']))
- if 'date' in task:
- output += "{}".format(task['date'])
+ output = first_line(t_id, task)
if 'description' in task:
output += "\n {}".format(task['description'])
if 'url' in task: