Commits

Thomas Noe committed 1b86fc8

toggle tasks to complete

Comments (0)

Files changed (2)

 
 TODO:
 	add docstrings
-	delete tasks
-	mark tasks as complete
 	break up the menu options into functions
 	argument parsing
 	project support
 		else:
 			return False
 
+	def toggle(self):
+		if self['status'] == 'i':
+			self['status'] = 'c'
+
 class Db(object):
 
 	def __init__(self, tasks=None):
 	
 	p) print tasklist 
 	a) add entry
+	t) toggle entry status
 	r) remove task
 	q) quit
 
 			except:
 				LOG.warning("Exception: Invalid input (remove)")
 
+		elif choice == 't':
+			# you can only toggle i -> c, not vis versa
+			try:
+				to_toggle = input("\tEnter the ID of the task to toggle > ")
+				db.tasks[to_toggle].toggle() # move toggle to Db class.
+
+			except:
+				LOG.warning("Exception: Invalid input(toggle)")
+
+
 		else:
 			print "\tError: %s is not a valid option" % choice
-
+		
 		choice = raw_input(prompt).lower()
 
 	with open(todo_file, 'wb') as f: