Skip to content

Align task list output for improved readability #575

@yzx9

Description

@yzx9

Problem

The current output of todo list is not column-aligned, making it harder to scan visually — especially when working with long lists or variable-width fields like:

  • Task ID
  • Priority (!, !!, etc.)
  • Date/time (particularly when humanize is enabled)

Example (content hidden for clarity):

[ ]  9  ! 2025-04-23 ...
[ ] 16 !! 2025-04-25 ...
[ ]  4  ! 2025-04-23 ...

Misaligned fields make it more difficult to quickly compare tasks.

Goal

Make the output easier to read by aligning the key fields: ID, priority, and date/time.

Proposed Solutions

Option 1: Fully automatic alignment

  • How: Read all rows first to determine the max width of each field before formatting output.
  • Pros: Cleanest and most flexible — adapts perfectly to the actual data.
  • Cons: Requires two passes — one to measure, one to render. However, this overhead is negligible in practice, as we're already assuming the data set is small enough to fit in stdout.

Option 2: Field-specific width estimation (no full scan)

  • How: Avoid reading all lines by estimating widths per field:
    • ID: Only need the max task ID.
    • Priority: Assume a max width (e.g. 3 chars: !!!).
    • Datetime: The width of formatted or humanized datetime can be calculated from the format string.
  • Pros: Single-pass output, more efficient.
  • Cons: Slight risk of over/under-aligning in edge cases (e.g. if importance ever exceeds assumed width).

I’m happy to help implement this if there's interest in improving the task list formatting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions