Skip to content

Harmonized table output across commands using tabled - #19

Merged
evoggy merged 2 commits into
mainfrom
evoggy/harmonize-tables
Sep 24, 2026
Merged

evoggy merged 2 commits into
mainfrom
evoggy/harmonize-tables

Conversation

@evoggy

@evoggy evoggy commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Every command that printed a table rolled its own, with hardcoded column
widths: param list padded names to 30 characters, log list to 30, lps
used a different two-space style, mem list wasn't columnar at all, and
deck list had a third variant. A value longer than its hardcoded width
pushed the row out of alignment.

This switches them all to tabled behind
two helpers in utils::display:

pub fn table<I>(rows: I) -> Table where I: IntoIterator, I::Item: Tabled
pub fn print_table(table: &Table)

table() applies the house style in one place — | separators, a dashed rule
under the header with + junctions, columns sized to their content. print_table() prints it
without trailing whitespace. Rows are described with #[derive(Tabled)]
structs, so the column headers live next to the data instead of in a format
string.

Converted: param list, param get, log list, mem list, loco display,
the anchor-positions file listing, and deck list (which drops the hand-rolled
helper added in #18).

Deliberately left alone: test.rs, scan, lighthouse and bootloader info
print label/value blocks and single-column lists, not tables — forcing those
into a grid would read worse.

The style is unchanged in spirit but columns now fit their content:

$ cfcli mem list
ID | Type         | Size                    | Serial
---+--------------+-------------------------+------------------
 0 | EEPROMConfig | 8191 (0x1fff)           |
 3 | OneWire      | 112 (0x70)              | 0D0AB362010000CA
 4 | DeckMemory   | 1342177280 (0x50000000) |

mem list is the one visible format change — it used to print
[0] EEPROMConfig size=7k (0x1fff/8191) per line.

Numeric columns (mem list ID, anchor IDs) are right-aligned and param's
Access column stays centred, as before.

All --csv output paths are untouched.

Dependency

tabled adds 6 crates to a 440-crate tree (tabled, tabled_derive,
papergrid, bytecount, fnv, testing_table). unicode-width, syn,
quote and heck were already present via indicatif/inquire. It also fixes
display width for wide characters, which the hand-rolled version got wrong.

Testing

param list, param get, log list, mem list and deck list verified
against a Crazyflie with a Lighthouse deck attached; the anchor-positions
listing against a file. Empty result sets render as header + rule, as before.

The doc examples in docs/memory.md, docs/logging.md, docs/parameters.md
and docs/deck.md are updated to match the new output.

@evoggy
evoggy merged commit 59374b8 into main Sep 24, 2026
1 check 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