Skip to content

feat(output): add TableColumn::align for right-aligned table columns - #94

Open
jpage-godaddy wants to merge 2 commits into
mainfrom
right-aligned-columns
Open

feat(output): add TableColumn::align for right-aligned table columns#94
jpage-godaddy wants to merge 2 commits into
mainfrom
right-aligned-columns

Conversation

@jpage-godaddy

@jpage-godaddy jpage-godaddy commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds an Alignment enum (Left/Right, default Left) and a TableColumn::align(Alignment) builder so a column's header and cells can be right-aligned in human table output — useful for numeric/price columns where left alignment leaves decimal points ragged.
  • Threads alignment through render_array_with_columns/render_table; nested tables pick it up automatically since they route through the same rendering path.
  • Exports Alignment from output::mod and the crate root alongside TableColumn.
  • Documents the new builder in docs/concepts.md.

Implements DEVEX-1014

Test plan

  • cargo fmt --all --check
  • cargo clippy --all-targets -- -D warnings
  • RUSTDOCFLAGS='-D warnings' cargo doc --no-deps
  • cargo test --all-targets (piped, non-TTY width)
  • cargo test --doc
  • cargo rustdoc --lib -- -W missing-docs (zero missing docs)
  • New unit tests for right-aligned padding + left-align default in src/output/human.rs
  • New integration test reproducing the ticket's price-table scenario in tests/exhaustive_output.rs

🤖 Generated with Claude Code

Numeric/price columns render left-aligned today, which reads poorly
when values are different widths (decimal points don't line up).
Adds an Alignment enum and TableColumn::align builder so a column's
header and cells can be right-aligned instead.

Fixes DEVEX-1014

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class right/left alignment support for human table output, enabling numeric/price columns to be right-aligned while preserving existing defaults and view behavior across nested tables.

Changes:

  • Introduces Alignment (Left/Right) and a TableColumn::align(Alignment) builder.
  • Threads column alignment through the human table rendering pipeline (render_array_with_columnsrender_table).
  • Adds unit + integration coverage for right-aligned tables and documents the new API in concepts docs.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
cli-engine/src/output/human.rs Adds Alignment, TableColumn::align, and applies alignment during table padding/rendering; includes new unit tests.
cli-engine/src/output/mod.rs Re-exports Alignment from output module.
cli-engine/src/lib.rs Re-exports Alignment at the crate root for public consumption.
cli-engine/tests/exhaustive_output.rs Adds an integration test asserting right-aligned price columns in human output.
cli-engine/docs/concepts.md Documents TableColumn::align(Alignment::Right) and its rendering scope.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cli-engine/src/output/human.rs Outdated
Comment thread cli-engine/src/output/human.rs
Comment thread cli-engine/docs/concepts.md Outdated
Fix "ragging" -> "looking ragged" grammar in the doc comment and
concepts.md, and rename the default-alignment test to stop implying
it exercises Alignment::Right when it verifies the Left default.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Suppressed comments (1)

cli-engine/docs/concepts.md:623

  • This bullet is a single very long line, while surrounding bullets are wrapped for readability. Wrapping it to match the local style will keep diffs and future edits easier to scan.
- `TableColumn::align(Alignment::Right)` right-aligns a column's header and cells (the default is `Alignment::Left`) — use it for numeric or price columns so digits and decimal points line up instead of looking ragged on the left. Only affects table rendering; a property-bag `key: value` line has no column width to align against.

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.

2 participants