feat(format): expand pow_format modifiers

Extend the pow_format spec parser beyond alignment so configs can shape the
rendered number, not just pad it. A forced scale (#, k, M, G, T, P) pins the SI
prefix instead of auto-selecting it and, since the author then knows both scale
and unit, hides the prefix and unit by default; U brings the unit back, u hides
it in auto mode, and i forces integer display. b and B override the decimal or
binary base independently of the call site, and a trailing width now fixes the
coefficient field when a scale is forced, overflowing to '#' when it does not
fit.

The old '>' and '<' branches rendered via fmt::format("{}", s), which discarded
every new field on the recursive call; they now build from a single render path
that reads the current formatter, so modifiers survive alignment. The auto path
is byte-identical to before, verified against the previous implementation.

Adds a Catch2 suite covering each modifier alone and combined, plus the
backward-compatible alignment cases, and documents the modifiers in the network
and disk man pages.
This commit is contained in:
Guillaume Maudoux
2026-07-04 23:08:42 +02:00
parent 2d9b95e9de
commit a3dc55f9ee
5 changed files with 273 additions and 44 deletions
+1
View File
@@ -13,6 +13,7 @@ test_src = files(
'../../src/config.cpp',
'JsonParser.cpp',
'SafeSignal.cpp',
'format.cpp',
'sleeper_thread.cpp',
'command.cpp',
'command_line_stream.cpp',