Project

alt_printf

0.0
No release in over 3 years
Low commit activity in last 3 years
A powerful printf-like template language
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 12.3
 Project Readme

altprintf

builds.sr.ht status

altprintf is a string template language. It was designed with a very specific goal in mind: allowing users to customize a program's functionality through the use of format strings.

Features

  • Cool format specifiers, like conditionals.
  • UTF-8 character width sensitive alignment
  • Nesting expressions
  • Robust
    • the library makes no memory allocations
    • an advanced error reporting system
    • fuzz testing based on the grammar in the docs
  • Template strings are compiled into a custom binary format
    • this saves resources when reusing the same template

Note that altprintf is not designed to replace printf. It is designed with the specific use case of providing user-specified templates to customize output.

Example

Here is an example format string to build a statusline for something like swaybar.

{win} {fetching?⇄ }{locked?閉 }{mail?〒{mail} }{cpu:> 3}% {temp}c {bat} {time}

Which could result in a string like:

mochiro.moe -- Mozilla Firefox 〒4   3% 49c 45 08:56

Building

You need a compatible meson implementation. If you want man pages, you also need scdoc.

Example:

$meson setup build
$ninja -C build

Docs

See the man pages