pretty-table: add Cell struct with per-cell styling and horizontal span#63
pretty-table: add Cell struct with per-cell styling and horizontal span#63jiacai2050 merged 10 commits intomainfrom
Conversation
…separators Co-authored-by: jiacai2050 <3848910+jiacai2050@users.noreply.github.com>
|
能再给表格里的数据加上颜色吗?我看它是支持的 |
Co-authored-by: jiacai2050 <3848910+jiacai2050@users.noreply.github.com>
Co-authored-by: jiacai2050 <3848910+jiacai2050@users.noreply.github.com>
Co-authored-by: jiacai2050 <3848910+jiacai2050@users.noreply.github.com>
Co-authored-by: jiacai2050 <3848910+jiacai2050@users.noreply.github.com>
Co-authored-by: jiacai2050 <3848910+jiacai2050@users.noreply.github.com>
… for PR #63) Co-authored-by: jiacai2050 <3848910+jiacai2050@users.noreply.github.com>
Co-authored-by: jiacai2050 <3848910+jiacai2050@users.noreply.github.com>
…al column widths Co-authored-by: jiacai2050 <3848910+jiacai2050@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR performs a major refactoring of both simargs and pretty-table modules. The simargs API is modernized with a ParseOptions struct, renamed fields (args → options, positional_args → positional_arguments, program → program_name), and improved naming throughout. The pretty-table module gains a Cell struct with per-cell ANSI styling (bold, italic, fg/bg colors), column alignment, row separators, and horizontal column spanning (hspan).
Changes:
- Refactored
simargspublic API: introducedParseOptionsstruct, renamedStructArgumentstoParseResult, and updated all callers across binaries and examples. - Enhanced
pretty-tablewithCell,Color,Aligntypes, column spanning support, and row separators, replacing rawStringrows. - Added TigerStyle coding guidelines skill file and updated documentation.
Reviewed changes
Copilot reviewed 6 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/mod/simargs.zig | Major API refactor: ParseOptions, renamed types/fields, improved naming conventions |
| src/mod/pretty-table.zig | New Cell/Color/Align types, hspan support, alignment, row separators, extensive tests |
| src/bin/*.zig | Updated all callers to new simargs API (options, positional_arguments, ParseOptions) |
| examples/simargs-demo.zig | Updated to new simargs API |
| examples/pretty-table-demo.zig | Rewritten to showcase new pretty-table features |
| docs/content/packages/pretty-table.org | Updated docs for Cell API and new features |
| .agents/skills/zig-tiger-style/SKILL.md | Added TigerStyle coding guidelines |
| src/bin/loc.zig | Updated to use Cell for table data |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
src/mod/simargs.zig
Outdated
| return switch (@typeInfo(option_type)) { | ||
| .int => |int_info| int_info.signedness, | ||
| .optional => |optional_info| getSignedness(optional_info.child), | ||
| else => .unsigned, |
src/mod/simargs.zig
Outdated
| comptime Options: type, | ||
| ) OptionType { | ||
| return Self.convert(T, false); | ||
| return Self.convert(Options, false); |
src/mod/simargs.zig
Outdated
| pub const ParseOptions = struct { | ||
| argument_prompt: ?[]const u8 = null, | ||
| version_string: ?[]const u8 = null, | ||
| }; |
…ll file Co-authored-by: jiacai2050 <3848910+jiacai2050@users.noreply.github.com>
Adds a
Celltype topretty-tableenabling per-cell ANSI styling (bold, italic, fg/bg color) and horizontal column spanning (hspan). Previously rows were[n][]const u8; now they are[n]Cell, withCell.init(text)as the zero-cost default path.API changes (
src/mod/pretty-table.zig)Cellstruct with builder methods:init,span,withBold,withItalic,withFg,withBg,withHspanRow(n)is now[n]Cell; plain-text usage wraps strings withCell.init(...)Tablegainscolumn_align,padding, androw_separatorfieldscell_colors,header_color,footer_colorfields (superseded by per-cell styling)Span usage example
Consumers updated
src/bin/loc.zig: rows and header updated from[]const u8toCell.init(...)wrappers — no behavioral changeexamples/pretty-table-demo.ziganddocs/content/packages/pretty-table.orgupdated to reflect new APIScope
src/mod/simargs.zigand all othersrc/bin/*.zigfiles are unchanged from the merge base — this PR is strictly scoped topretty-table.Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.