Skip to content

Add --human=iec|si size units to --summary (#86 PR B) - #203

Merged
helly25 merged 1 commit into
mainfrom
feat/summary-human-sizes
Jul 2, 2026
Merged

Add --human=iec|si size units to --summary (#86 PR B)#203
helly25 merged 1 commit into
mainfrom
feat/summary-human-sizes

Conversation

@helly25

@helly25 helly25 commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Completes #86 on the #202 formatter. format::Size(bytes, SizeUnits) renders a human size (du -h / ls -h): exact bytes under one unit (56 B), else scaled to the largest fitting unit with one decimal (5.6 MiB, 5.9 MB). kIec = binary (1024, KiB/MiB, matching -size); kSi = decimal (1000, kB/MB).

--human[=iec|si] switches the --summary size column to units - bare --human/=iec binary, =si decimal, absent = raw grouped bytes (last wins). Affects only the human table; --format=jsonl keeps exact byte counts (the machine path).

bin    1  5.6 MiB     bin    1  5.9 MB      (raw:  bin  1  5,872,025)
total  2  5.6 MiB     total  2  5.9 MB
   --human               --human=si

Self-doc: --human GlobalFlag (Output) + kHelpText.
Tests: format_test Size (iec + si across the range, exact-bytes boundary); cli/summary_test.sh iec/si rendering + jsonl bytes unchanged by --human. bazel test //... green (35 tests).

Completes #86: format::Size(bytes, SizeUnits) renders a human-readable size (du -h /
ls -h style) -- exact bytes under one unit ("56 B"), else the value scaled to the
largest fitting unit with one decimal ("5.6 MiB", "5.9 MB"). kIec is binary (1024,
KiB/MiB, matching -size); kSi is decimal (1000, kB/MB).

--human[=iec|si] switches the --summary size column to units: bare --human / =iec is
binary, =si decimal, absent stays raw grouped bytes; last occurrence wins. It affects
only the human table -- --format=jsonl keeps exact byte counts (the machine path).

Self-documentation: --human GlobalFlag (Output group) + kHelpText.

Tests: format_test Size (iec + si across the unit range, exact-bytes boundary);
cli/summary_test.sh --human iec/si rendering + that jsonl bytes are unchanged by
--human. bazel test //... green (35 tests).
@helly25
helly25 enabled auto-merge (squash) July 2, 2026 18:28
@helly25
helly25 merged commit 4370ff3 into main Jul 2, 2026
8 checks passed
@helly25
helly25 deleted the feat/summary-human-sizes branch July 2, 2026 18:34
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.
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