Module: manager
File: C:\Users\korde\Home\Github\task-runner-SDLC\src\manager.py
Language: Python
Description
Task management module for handling task operations.
Imports
import loggingfrom pathlib import Pathfrom typing import Listfrom typing import Dictfrom typing import Anyfrom config import Configfrom utils.file_system import load_json_filefrom utils.file_system import save_json_file
Functions
add_task()
Add a new task (legacy interactive function).
list_tasks()
List all tasks (legacy print function).
Classes
Class: TaskManager
Manages task operations including creation, retrieval, and updates.
Methods
__init__(self, tasks_file: str = None)
Initialize TaskManager with specified tasks file.
Args: tasks_file: Path to tasks JSON file. Defaults to Config.TASKS_FILE.
Parameters
selftasks_file(str) — defaults toNone
_get_next_id(self, tasks: List[Dict[(str, Any)]]) -> int
Generate next available task ID.
Parameters
selftasks(List[Dict[(str, Any)]])
Returns
int
_load_tasks(self) -> List[Dict[(str, Any)]]
Load tasks from JSON file.
Parameters
self
Returns
List[Dict[(str, Any)]]
_save_tasks(self, tasks: List[Dict[(str, Any)]]) -> None
Save tasks to JSON file.
Parameters
selftasks(List[Dict[(str, Any)]])
Returns
None
add_task(self, title: str, description: str = '', tags: List[str] = None, status: str = 'todo') -> Dict[(str, Any)]
Add a new task.
Args: title: Task title (required) description: Task description tags: List of task tags status: Task status (default: 'todo')
Returns: The newly created task dictionary
Parameters
selftitle(str)description(str) — defaults to''tags(List[str]) — defaults toNonestatus(str) — defaults to'todo'
Returns
Dict[(str, Any)]
delete_task(self, task_id: int) -> bool
Delete a task by ID.
Args: task_id: The task ID to delete
Returns: True if task was deleted, False if not found
Parameters
selftask_id(int)
Returns
bool
get_task(self, task_id: int) -> Dict[(str, Any)]
Get a specific task by ID.
Args: task_id: The task ID to retrieve
Returns: Task dictionary or None if not found
Parameters
selftask_id(int)
Returns
Dict[(str, Any)]
list_tasks(self, status_filter: str = None) -> List[Dict[(str, Any)]]
List all tasks, optionally filtered by status.
Args: status_filter: Optional status to filter tasks by
Returns: List of task dictionaries
Parameters
selfstatus_filter(str) — defaults toNone
Returns
List[Dict[(str, Any)]]
update_task(self, task_id: int, **updates) -> bool
Update task fields.
Args: task_id: The task ID to update **updates: Field names and values to update
Returns: True if task was updated, False if not found
Parameters
selftask_id(int)**updates
Returns
bool