-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask_status.py
More file actions
executable file
·56 lines (46 loc) · 1.7 KB
/
task_status.py
File metadata and controls
executable file
·56 lines (46 loc) · 1.7 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
#!/usr/bin/env python3
"""
CLI command to display task items grouped by status: Completed, In-Progress, and Todo.
Accepts a GUID to identify the task directory.
Uses task_parser.py to read task.md and extract checklist items.
"""
import os
import sys
from pathlib import Path
from task_parser import parse_task_md, get_task_summary
def main():
if len(sys.argv) != 2:
print("Usage: task-status <guid>", file=sys.stderr)
sys.exit(1)
guid = sys.argv[1]
task_path = Path.cwd() / guid
# Check if task directory exists
if not task_path.exists() or not task_path.is_dir():
print(f"Error: Invalid GUID '{guid}' - directory not found", file=sys.stderr)
sys.exit(1)
# Get task summary to validate GUID
try:
summary = get_task_summary(task_path)
if summary['guid'] != guid:
print(f"Error: Invalid GUID '{guid}' - directory name mismatch", file=sys.stderr)
sys.exit(1)
except Exception:
print(f"Error: Invalid GUID '{guid}' - cannot read task metadata", file=sys.stderr)
sys.exit(1)
# Parse task.md
task_data = parse_task_md(task_path)
# Display results
if task_data['completed']:
print("Completed Tasks:")
for i, item in enumerate(task_data['completed']):
print(f"[{i}] {item['text']}")
if task_data['in_progress']:
print("\nIn-Progress Tasks:")
for i, item in enumerate(task_data['in_progress']):
print(f"[{i}] {item['text']}")
if task_data['todo']:
print("\nTodo List:")
for i, item in enumerate(task_data['todo']):
print(f"[{i}] {item['text']}")
if __name__ == "__main__":
main()