Skip to content

Commit de4a89c

Browse files
committed
update starter code for models.py and cli_tool.py
1 parent 1c0ed71 commit de4a89c

File tree

3 files changed

+32
-27
lines changed

3 files changed

+32
-27
lines changed

.DS_Store

6 KB
Binary file not shown.

lib/cli_tool.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,38 @@
1-
# lib/cli_tool.py
1+
# cli_tool.py
22

33
import argparse
4-
from lib.models import Task, User
4+
from models import Task, User
55

6-
# Global in-memory dictionary to hold user-task mappings
6+
# Global dictionary to store users and their tasks
77
users = {}
88

9-
# TODO: Define a function to add a task
9+
# TODO: Implement function to add a task for a user
1010
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
1514
pass
1615

17-
# TODO: Define a function to complete a task
16+
# TODO: Implement function to mark a task as complete
1817
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
2322
pass
2423

25-
# Main CLI handler using argparse
24+
# CLI entry point
2625
def main():
2726
parser = argparse.ArgumentParser(description="Task Manager CLI")
2827
subparsers = parser.add_subparsers()
2928

30-
# Subparser for adding a task
29+
# Subparser for adding tasks
3130
add_parser = subparsers.add_parser("add-task", help="Add a task for a user")
3231
add_parser.add_argument("user")
3332
add_parser.add_argument("title")
3433
add_parser.set_defaults(func=add_task)
3534

36-
# Subparser for completing a task
35+
# Subparser for completing tasks
3736
complete_parser = subparsers.add_parser("complete-task", help="Complete a user's task")
3837
complete_parser.add_argument("user")
3938
complete_parser.add_argument("title")
@@ -45,6 +44,5 @@ def main():
4544
else:
4645
parser.print_help()
4746

48-
# Entry point
4947
if __name__ == "__main__":
5048
main()

lib/models.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,34 @@
1-
# lib/models.py
2-
31
# TODO: Define the Task class
4-
# Each task should store a title and a completion status (initially False)
2+
# Each task should store a title and a completed status (default False)
3+
# Add a complete() method that marks the task as completed and prints confirmation
4+
55
class Task:
66
def __init__(self, title):
7-
# TODO: Set the title and initialize completed to False
7+
# TODO: Assign the title
8+
# TODO: Set completed to False
89
pass
910

1011
def complete(self):
11-
# TODO: Mark task as complete and print confirmation
12+
# TODO: Mark the task as complete
13+
# TODO: Print a confirmation message
1214
pass
1315

1416
# TODO: Define the User class
15-
# Each user should have a name and a list of tasks
17+
# Each user has a name and a list of tasks
18+
# Add methods to add tasks and search tasks by title
19+
1620
class User:
1721
def __init__(self, name):
18-
# TODO: Set the name and initialize the task list
22+
# TODO: Store the user's name
23+
# TODO: Initialize an empty list of tasks
1924
pass
2025

2126
def add_task(self, task):
22-
# TODO: Append the task to the user's list and print confirmation
27+
# TODO: Add the task to the user's task list
28+
# TODO: Print a message confirming the task was added
2329
pass
2430

2531
def get_task_by_title(self, title):
26-
# TODO: Return the task if the title matches, or return None
27-
pass
32+
# TODO: Search for a task by its title in the user's task list
33+
# TODO: Return the matching task or None
34+
pass

0 commit comments

Comments
 (0)