1313 "10" : "Quit"
1414 }
1515
16- def list_options ():
1716
17+ def list_options ():
1818 for number , feature in OPTIONS .items ():
1919 print (f"{ number } . { feature } " )
2020
@@ -29,14 +29,15 @@ def make_choice():
2929
3030 return choice
3131
32+
3233def get_task_from_user (msg = "Input the id of the task you would like to work with: " ):
3334 task = None
3435 tasks = task_list .list_tasks ()
3536 if not tasks :
3637 task_list .print_stars ("This option is not possible because there are no tasks." )
3738 return task
3839 count = 0
39- help_count = 3 #number of tries before offering assistance
40+ help_count = 3 # number of tries before offering assistance
4041 while not task :
4142 id = input (msg )
4243 task = task_list .get_task (id )
@@ -49,6 +50,7 @@ def get_task_from_user(msg = "Input the id of the task you would like to work wi
4950
5051 return task
5152
53+
5254def print_task (task ):
5355 print_single_row_of_stars ()
5456 print ("title: " , task ["title" ])
@@ -57,45 +59,56 @@ def print_task(task):
5759 print ("id: " , task ["id" ])
5860 print_single_row_of_stars ()
5961
62+
6063def print_all_tasks ():
6164 tasks = task_list .list_tasks ()
65+
6266 print ("\n Tasks:" )
6367 if not tasks :
6468 print_surround_stars ("No tasks" )
6569 else :
6670 for task in tasks :
6771 print_task (task )
72+
6873 print_single_row_of_stars ()
6974
75+
7076def print_surround_stars (sentence ):
7177 print_single_row_of_stars ()
7278 print (sentence )
7379 print_single_row_of_stars ()
7480
81+
7582def print_single_row_of_stars ():
7683 print ("\n **************************\n " )
7784
85+
7886def create_task ():
7987 print ("Great! Let's create a new task." )
8088 title = input ("What is the title of your task? " )
8189 description = input ("What is the description of your task? " )
8290 response = task_list .create_task (title , description )
8391 print_task (response )
8492
93+
8594def view_task ():
8695 task = get_task_from_user ("Input the id of the task you would like to select " )
8796 if task :
8897 print ("\n Selected Task:" )
8998 print_task (task )
9099
100+
91101def edit_task ():
92102 task = get_task_from_user ()
93103 if task :
94104 title = input ("What is the new title of your task? " )
95105 description = input ("What is the new description of your task? " )
96- response = task_list .update_task (task ["id" ], title , description )
106+ task_list .update_task (task ["id" ], title , description )
107+
97108 print ("\n Updated Task:" )
98- print_task (response )
109+ updated_task = task_list .get_task (task ["id" ])
110+ print_task (updated_task )
111+
99112
100113def delete_task_ui ():
101114 task = get_task_from_user ("Input the id of the task you would like to delete: " )
@@ -104,26 +117,30 @@ def delete_task_ui():
104117 print ("\n Task has been deleted." )
105118 print_all_tasks ()
106119
120+
107121def change_task_complete_status (status ):
108122 status_text = "complete"
109123 if not status :
110124 status_text = "incomplete"
111125 task = get_task_from_user (f"Input the id of the task you would like to mark { status_text } : " )
112126 if task :
113127 if status :
114- response = task_list .mark_complete (task ["id" ])
128+ task_list .mark_complete (task ["id" ])
115129 else :
116- response = task_list .mark_incomplete (task ["id" ])
130+ task_list .mark_incomplete (task ["id" ])
131+
117132 print (f"\n Task marked { status_text } :" )
118- print_task (response )
133+ updated_task = task_list .get_task (task ["id" ])
134+ print_task (updated_task )
135+
119136
120137def delete_all_tasks ():
121138 for task in task_list .list_tasks ():
122139 task_list .delete_task (task ["id" ])
123140 print_surround_stars ("Deleted all tasks." )
124141
142+
125143def run_cli ():
126-
127144 play = True
128145 while play :
129146
0 commit comments