Commit aa7dfc27 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Print a bit more feedback on several actions.

parent d3956d60
...@@ -6,6 +6,7 @@ import sys ...@@ -6,6 +6,7 @@ import sys
import Config import Config
import Filter import Filter
from PrettyPrinter import pretty_print
import Sorter import Sorter
import TodoFile import TodoFile
import TodoList import TodoList
...@@ -31,10 +32,18 @@ class Application(object): ...@@ -31,10 +32,18 @@ class Application(object):
self.todolist = TodoList.TodoList([]) self.todolist = TodoList.TodoList([])
self.dirty = False self.dirty = False
def print_todo(self, p_number):
""" Prints a single todo item to the standard output. """
todo = self.todolist.todo(p_number)
printed = pretty_print([todo], True, True)
print printed[0]
def add(self): def add(self):
""" Adds a todo item to the list. """ """ Adds a todo item to the list. """
try: try:
self.todolist.add(sys.argv[2]) self.todolist.add(sys.argv[2])
self.print_todo(todo.number) # TODO
self.dirty = True self.dirty = True
except IndexError: except IndexError:
error("No todo text was given.") error("No todo text was given.")
...@@ -49,6 +58,8 @@ class Application(object): ...@@ -49,6 +58,8 @@ class Application(object):
try: try:
number = int(number) number = int(number)
self.todolist.append(number, text) self.todolist.append(number, text)
self.print_todo(number)
self.dirty = True self.dirty = True
except ValueError: except ValueError:
error("Invalid todo number given.") error("Invalid todo number given.")
...@@ -62,6 +73,8 @@ class Application(object): ...@@ -62,6 +73,8 @@ class Application(object):
try: try:
number = int(number) number = int(number)
self.todolist.todo(number).set_completed() self.todolist.todo(number).set_completed()
self.print_todo(number)
self.dirty = True self.dirty = True
except IndexError: except IndexError:
usage() usage()
...@@ -78,7 +91,13 @@ class Application(object): ...@@ -78,7 +91,13 @@ class Application(object):
if re.match('^[A-Z]$', priority): if re.match('^[A-Z]$', priority):
try: try:
number = int(number) number = int(number)
self.todolist.todo(number).set_priority(priority) todo = self.todolist.todo(number)
old_priority = todo.priority()
todo.set_priority(priority)
print "Priority changed from %s to %s" \
% (old_priority, priority)
self.print_todo(number)
self.dirty = True self.dirty = True
except AttributeError: except AttributeError:
error("Invalid todo number given.") error("Invalid todo number given.")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment