--summary human sizes: align number/suffix columns + --summary-precision - #235
Merged
Conversation
The human size column right-aligned each "N.N XiB" string as a whole, so units were
ragged and decimal points did not line up ("2.4 MiB" over "2 B" over "1.5 KiB"). Split
the size into two columns: a right-aligned number with a fixed fraction area (so points
line up, blanked for exact bytes) and a left-aligned unit suffix that starts at one
column. Bytes render as the integer with the fraction columns blanked (12 B, not the
12.00 B "cringe"), so a byte row still lines up under the scaled rows:
log 1 2.38 MiB
md 1 2 B
txt 2 1.47 KiB
total 4 2.39 MiB
New --summary-precision=N sets the scaled-unit fraction digits (default 2; 0 drops the
point). --human=off (raw grouped bytes) is unchanged.
format::SizeColumns(bytes, units, fraction_digits) returns the {number, suffix} split
(sharing ScaleSize with format::Size); the summary renderer pads the number column to its
widest cell and appends " " + suffix. Self-doc: the --summary-precision GlobalFlag; --help
/ --man / --markdown regenerate. Tests: format_test (SizeColumns split, byte blanking,
zero precision), summary_test (byte spacing, precision control), and the summary golden.
helly25
enabled auto-merge (squash)
July 4, 2026 08:45
helly25
added a commit
that referenced
this pull request
Jul 6, 2026
Remove five stale 'to do' bullets that describe already-implemented work, so TODO.md stops listing done features as open: - Right align numbers in summary -> shipped (#202, #235) - More output control for summary -> shipped (#86, #203, #275) - Align outputs like -ls -> shipped (#205, #206, #207) - Mimetype support -> shipped (#219 -mime) - File type support -> shipped (#262 -lang, #89) Fix the 'Color support' cross-reference that pointed at the removed 'File type support' bullet to name -lang / {lang} / languages.yml directly. Genuinely-open items (Line count {lines} field, per-file hashes, --sort/-j CLI test, histograms #81) are untouched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
--summaryhuman size column right-aligned eachN.N XiBstring as a whole, so units were ragged and decimal points didn't line up. This splits the size into two aligned columns.Before
After (numbers right-aligned with a fixed fraction area so points line up; suffixes left-aligned, all starting at one column; exact bytes render as the integer with the fraction columns blanked)
12 B(integer, fraction area blanked to keep the point aligned), not the12.00 B"cringe".--summary-precision=Nsets the scaled-unit fraction digits (default 2, matching the123.45target;0drops the point).--human=off(raw grouped bytes) is unchanged.format::SizeColumns(bytes, units, fraction_digits)returns the{number, suffix}split (sharing a newScaleSizewithformat::Size); the summary renderer pads the number column to its widest cell and appends" " + suffix.Self-doc: the
--summary-precisionGlobalFlag(so--help/--man/--markdownpick it up). Tests:format_test(split, byte blanking, zero precision),summary_test(byte spacing + precision control), and thesummary_additivegolden regenerated. Fullbazel test //xff/...green (49); both clang-format versions + shfmt/shellcheck + pre-commit clean.Note: this makes the aligned layout the default for
--summary(the old ragged format is replaced, not kept as a toggle) since--summaryis always tabular. Easy to gate behind a flag instead if you'd prefer.