Skip to content

refactor: one Table/JSON output module for the list commands - #43

Merged
frantufro merged 2 commits into
mainfrom
refactor/output-module
Nov 13, 2026
Merged

frantufro merged 2 commits into
mainfrom
refactor/output-module

Conversation

@frantufro

Copy link
Copy Markdown
Owner

Summary

  • New src/commands/output.rs: render/print take a Format (Table or Json), headers and rows of Cell (Text, Number, Null). It owns column widths (char count), padding (last column unpadded), the -/null rendering of missing values and JSON escaping via serde_json.
  • commands/list.rs and commands/roadmap/list.rs now only map their rows to cells. Both copies of render_table, write_row, render_json and push_json_string are deleted.
  • Row and column rules are unit-tested once in the output module. CLI output is unchanged; tests/list.rs and tests/roadmap.rs pass untouched.
  • Task add-one-table-json-output-module moved to done.

Escaping check

serde_json matches the old hand-written escaper on quotes, backslash, \n, \r, \t, \b, \f, other control chars (lowercase \u00xx, e.g. \u0001, \u001f) and non-ASCII (emitted raw). The unit test json_escapes_quotes_backslash_and_controls covers these. No difference found. DEL (0x7f) is emitted raw by both.

Verification

  • cargo fmt
  • cargo clippy --all-targets -- -D warnings -W clippy::pedantic (local default toolchain, not the pinned 1.98.0)
  • cargo test --locked

@frantufro
frantufro force-pushed the refactor/output-module branch from b15d18f to 5213589 Compare November 13, 2026 13:01
TaskDoc parses and renders frontmatter, the H1 title and the body.
core/frontmatter.rs moves into core/task_doc.rs, the H1 rule and
read_body are shared by both new commands, and list reads metadata
through TaskDoc. File output is unchanged.
Both list commands now build rows of cells and call commands::output,
which owns column widths, padding and JSON escaping (via serde_json).
@frantufro
frantufro force-pushed the refactor/output-module branch from 5213589 to 4d88e28 Compare November 13, 2026 13:19
@frantufro
frantufro merged commit b72c2c5 into main Nov 13, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant