-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask_manager.py
More file actions
90 lines (85 loc) · 3.33 KB
/
Copy pathtask_manager.py
File metadata and controls
90 lines (85 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
from utils import load_tasks, save_tasks, get_key, clear_screen
def print_tasks(tasks, selected_index):
print("="*60)
print("🛡️ INVESTIGATION TASK MANAGER - Academy of Computation")
print("="*60)
print()
if len(tasks)==0:
print("No tasks yet. Press 'a' to add a task.")
return
for task_index, task in enumerate(tasks):
if selected_index==task_index:
if task["is_complete"]:
indicator = "[*]"
else:
indicator= "(*)"
else:
if task["is_complete"]:
indicator ="[x]"
else:
indicator="( )"
priority_display = f"Priority: {task.get('priority', 'medium')}"
location_display = f"Location: {task.get('location', 'N/A')}"
print(f"{indicator} {task['label']}")
print(f" {priority_display} | {location_display}")
print()
def main():
tasks = load_tasks()
selected_index=0
# tasks=[
# {"label": "Investigate Riley Hall energy readings", "is_complete": False, "priority": "high", "location": "Riley Hall"},
# {"label": "Check Library bookshelf anomalies", "is_complete": False, "priority": "medium", "location": "Library"},
# {"label": "Review Clock Tower sensor data", "is_complete": True, "priority": "high", "location": "Clock Tower"},
# ]
while True:
clear_screen()
print_tasks(tasks, selected_index)
print("Controls: ↑/↓ to select | Enter to toggle | 'a' to add | 'd' to delete | 'q' to quit")
key=get_key()
if key and key.lower() =="q":
save_tasks(tasks)
print("\n👋 Tasks saved. Exiting task manager.")
break
if key=="up":
if len(tasks) >0:
selected_index = (selected_index -1) % len(tasks)
elif key =="down":
if len(tasks) >0:
selected_index =(selected_index+1) % len(tasks)
if key =="enter":
if len(tasks) >0:
tasks[selected_index]["is_complete"] = not tasks[selected_index]["is_complete"]
save_tasks(tasks)
if key =="a":
clear_screen()
print("➕ Add New Investigation Task")
print("="*60)
label =input("Task description: ").strip()
if not label:
continue
priority = input("Priority (high/medium/low) [medium]: ").strip().lower()
if not priority:
priority="medium"
location =input("Location: ").strip()
if not location:
location ="N/A"
new_task ={
"label": label,
"is_complete": False,
"priority": priority,
"location": location
}
tasks.append(new_task)
save_tasks(tasks)
selected_index =len(tasks) -1
if key =="d":
if len(tasks)>0:
deleted_task = tasks.pop(selected_index)
print(f"\n🗑️ Deleted: {deleted_task['label']}")
if selected_index>=len(tasks) and len(tasks) >0:
selected_index=len(tasks) -1
elif len(tasks) ==0:
selected_index=0
save_tasks(tasks)
if __name__== "__main__":
main()