To-Do List Skill
Manage tasks using a local JSON file.
Add Task
python3 -c "
import json, os
path = os.path.expanduser('~/todos.json')
todos = json.load(open(path)) if os.path.exists(path) else []
todos.append({'id': len(todos)+1, 'task': '{task}', 'priority': '{priority}', 'done': False})
json.dump(todos, open(path, 'w'), indent=2)
print('Added:', '{task}')
"
List Tasks
python3 -c "
import json, os
path = os.path.expanduser('~/todos.json')
todos = json.load(open(path)) if os.path.exists(path) else []
for t in sorted(todos, key=lambda x: x.get('done', False)):
status = '[x]' if t['done'] else '[ ]'
print(f'{status} #{t["id"]} [{t.get("priority","normal")}] {t["task"]}')
"
Complete Task
python3 -c "
import json, os
path = os.path.expanduser('~/todos.json')
todos = json.load(open(path))
for t in todos:
if t['id'] == {id}: t['done'] = True
json.dump(todos, open(path, 'w'), indent=2)
print('Completed task #{id}')
"
Notes
- Priorities: high, medium, low
- Stored at ~/todos.json