Track task-list (checkbox) progress
Goal: Count how many - [x] items are checked off out of the total in a Markdown task list — e.g. to report progress on a TODO list or project checklist.
Prerequisites: -A, since the counts are computed across the whole document at once.
Query
List only the completed items:
$ mq 'select(.list.checked == true)' TODO.md
Count done vs. total:
$ mq -A 'let total = count_by(fn(x): x | select(.list);)
| let done = count_by(fn(x): x | select(.list.checked == true);)
| s"${done}/${total} done"' TODO.md
Input
# TODO
- [x] Write docs
- [ ] Add tests
- [x] Fix bug
- [ ] Ship release
Output
2/4 done
Notes
- Shorthand:
.doneand.todoselect checked/unchecked task-list items directly —.doneis equivalent toselect(.list.checked == true), and.todotoselect(.list.checked == false). The counting query can useselect(.done)in place ofselect(.list.checked == true)the same way. .list.checkedistrue/falsefor task-list items and absent (None) for a plain bullet or numbered item — soselect(.list)alone counts every list item regardless of whether it’s a checkbox.- Swap
== truefor== false(or.donefor.todo) to list what’s left to do instead of what’s done.