Skip to content

feat: rich CLI output with tables and Description dedent - #38

Merged
N283T merged 16 commits into
mainfrom
feature/rich-cli-tables
Apr 16, 2026
Merged

feat: rich CLI output with tables and Description dedent#38
N283T merged 16 commits into
mainfrom
feature/rich-cli-tables

Conversation

@N283T

@N283T N283T commented Apr 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • Render relations, search, and the category NAME Items list as Unicode-boxed tables when stdout is a tty; tab-separated when piped
  • New --no-table flag forces plain TSV output regardless of tty
  • Description text strips the common leading whitespace mmCIF .dic files carry into multi-line strings; paragraphs now read as intended
  • Breaking (shell parsing): piped output of relations and search is now tab-separated columns instead of prose. Machine consumers should use --json.

Approach

  • New src/term.zig: isTty wrapping std.posix.isatty, width via $COLUMNS (default 80). No libc, no ioctl.
  • New src/table.zig: self-hosted render (tsv/boxed) + renderGrid (single-column multi-line grid). 52 inline tests.
  • Refactored src/output.zig from format: Format to opts: Options carrying { format, text_style, terminal_width }. All print functions updated; main.zig call sites follow.
  • printRelations and printSearchResults take the caller's gpa and use short-lived arenas for row storage.

Test plan

  • Zig unit tests (zig build test) — 52 pass (term + table primitives + description dedent + existing)
  • Python smoke tests (uv run --script tests/test_smoke.py) — 25 pass (7 new: pipe-TSV shape, --no-table idempotence, --json ignores --no-table, items preserve 2-space legacy indent, --help mentions flag, pty-based boxed verification with POSIX skipif)
  • Manual: relations atom_site piped → TSV; on a real tty → Unicode box
  • JSON output byte-identical (verified by test_json_output_unchanged_by_table_flag)

Out of scope (follow-ups)

  • Colors / NO_COLOR handling
  • Pager integration
  • item command's Allowed values: section (not converted to grid)
  • Proper UTF-8 width for non-ASCII cells (module-level doc notes the ASCII-only contract)

@N283T
N283T merged commit 138119f into main Apr 16, 2026
1 check passed
@N283T
N283T deleted the feature/rich-cli-tables branch April 16, 2026 06:00
@N283T N283T mentioned this pull request Apr 16, 2026
3 tasks
N283T added a commit that referenced this pull request Apr 16, 2026
N283T added a commit that referenced this pull request Apr 16, 2026
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