1
- # lib/ cli_tool.py
1
+ # cli_tool.py
2
2
3
3
import argparse
4
- from lib . models import Task , User
4
+ from models import Task , User
5
5
6
- # Global in-memory dictionary to hold user-task mappings
6
+ # Global dictionary to store users and their tasks
7
7
users = {}
8
8
9
- # TODO: Define a function to add a task
9
+ # TODO: Implement function to add a task for a user
10
10
def add_task (args ):
11
- # TODO:
12
- # - Get or create a User instance
13
- # - Create a Task from the input title
14
- # - Add the Task to the User
11
+ # - Check if the user exists, if not, create one
12
+ # - Create a new Task with the given title
13
+ # - Add the task to the user's task list
15
14
pass
16
15
17
- # TODO: Define a function to complete a task
16
+ # TODO: Implement function to mark a task as complete
18
17
def complete_task (args ):
19
- # TODO:
20
- # - Find the user by name
21
- # - Use get_task_by_title to find the task
22
- # - Call the complete method or print an error
18
+ # - Look up the user by name
19
+ # - Look up the task by title
20
+ # - Mark the task as complete
21
+ # - Print appropriate error messages if not found
23
22
pass
24
23
25
- # Main CLI handler using argparse
24
+ # CLI entry point
26
25
def main ():
27
26
parser = argparse .ArgumentParser (description = "Task Manager CLI" )
28
27
subparsers = parser .add_subparsers ()
29
28
30
- # Subparser for adding a task
29
+ # Subparser for adding tasks
31
30
add_parser = subparsers .add_parser ("add-task" , help = "Add a task for a user" )
32
31
add_parser .add_argument ("user" )
33
32
add_parser .add_argument ("title" )
34
33
add_parser .set_defaults (func = add_task )
35
34
36
- # Subparser for completing a task
35
+ # Subparser for completing tasks
37
36
complete_parser = subparsers .add_parser ("complete-task" , help = "Complete a user's task" )
38
37
complete_parser .add_argument ("user" )
39
38
complete_parser .add_argument ("title" )
@@ -45,6 +44,5 @@ def main():
45
44
else :
46
45
parser .print_help ()
47
46
48
- # Entry point
49
47
if __name__ == "__main__" :
50
48
main ()
0 commit comments