todoman
todoman copied to clipboard
Improve alignment in todo list output
Problem
The current task list output is not column-aligned, which makes it hard to visually scan — especially with variable-width fields like task ID, priority, and date/time. This becomes more noticeable with long or complex lists.
What’s implemented
I've put together a working prototype that aligns the key fields (ID, priority, date/time) for better readability.
The new implementation refactors the original rendering logic into three clear steps: format, optional align, and style, based on a column configuration. Each column defines how its value is formatted, optionally aligned, and styled. This design makes the output easier to manage and extend.
It’s also future-proof: we can easily support custom output formats (e.g. via a user-defined column template string) without changing the rendering pipeline.
Examples
› python -m todoman
[ ] 5 ! 2025-04-25 18:41 Masked content @work
[ ] 23 !! 2025-05-26 10:52 Masked content A @home
[ ] 25 !! 2025-04-25 09:00 Masked content ABC [project]
[ ] 2 !!! 2025-04-25 22:30 Masked content ABCD @work
[ ] 20 !!! 2025-04-25 22:00 Masked content ABCDE @home
› python -m todoman --humanize
[ ] 5 ! 3 hours ago Masked content @work
[ ] 23 !! in 30 days Masked content A @home
[ ] 25 !! 13 hours ago Masked content ABC @home [project]
[ ] 2 !!! in 5 minutes Masked content ABCD @work
[ ] 20 !!! 24 minutes ago Masked content ABCDE @home
› python -m todoman --align never
[ ] 5 ! 2025-04-25 18:41 Masked content @work
[ ] 23 !! 2025-05-26 10:52 Masked content A @home
[ ] 25 !! 2025-04-25 09:00 Masked content ABC @home @home [project]
[ ] 2 !!! 2025-04-25 22:30 Masked content ABCD @work
[ ] 20 !!! 2025-04-25 22:00 Masked content ABCDE @home
Next steps
If there's interest in this improvement, I’m happy to continue with the remaining parts — including tests, documentation, and polish.
close #575
Thanks for your review and interest in this PR! I’ve fixed the issues you mentioned, except for the naming.
I’d also like to add some tests. But it turns out the testing utility todo_factory has a bug — it generates random IDs, making the behavior non-deterministic.
@WhyNotHugo Thanks for testing! I’ve skipped adding spaces after the last column if it is left-aligned.
BTW, there are two spaces in your copy-paste because no priority was assigned to any of the todos. We could filter out these empty columns if you're interested. But it would change the current behavior, so I would prefer to handle it in a separate PR.
Performance impact seems reasonable. I'm sure we can refine later if needed.
Before:
> hyperfine -- python -m todoman
Benchmark 1: python
Time (mean ± σ): 9.6 ms ± 1.2 ms [User: 7.4 ms, System: 2.2 ms]
Range (min … max): 8.2 ms … 13.7 ms 322 runs
After:
Benchmark 1: python
Time (mean ± σ): 16.1 ms ± 1.5 ms [User: 13.3 ms, System: 2.8 ms]
Range (min … max): 14.4 ms … 22.4 ms 183 runs
With 266 pending tasks and about 4k total files.
Resolved conflicts