Skip to content

Draft: WIP: add python/rust style format strings

Andrew Gregory requested to merge andrew/pformat into master

--print-format currently uses printf-style format strings, which have limited namespace (a-zA-Z), low flexibility (depends-with-version and depends-without-version have to be different sequences), and are difficult to remember (is %d depends or description?).

Python/Rust format strings allow full word substitutions. In addition, the mfmt.c library being used makes it possible to extend the standard formatting for much greater control. For example, we can allow nested templates so that instead of having "{depends}" and "{depends-without-version}" variants, we can allow something like "{depends<{name}={version}: {description}>}".

For example: pacman -Sp --pformat="{name}: {description} ({packager})" pacman

Obviously this is very much a work in progress, both for the formatting library and the alpm implementation, but given the recent interest in --print-format again, I wanted to get this in front of people.

Merge request reports