tmpl

Simple key-value templator
git clone https://git.sinitax.com/sinitax/tmpl
Log | Files | Refs | README | LICENSE | sfeed.txt

commit 190ebaffa70bdd72dc7f761c7380b3a9e84c76e4
parent a128a59911dd08740da02e365238e67bd4645710
Author: Louis Burda <quent.burda@gmail.com>
Date:   Sun, 18 Feb 2024 00:00:04 +0100

Add README and manpage

Diffstat:
MMakefile | 5++++-
AREADME | 17+++++++++++++++++
Atmpl.1 | 48++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 69 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile @@ -1,5 +1,6 @@ PREFIX ?= /usr/local BINDIR ?= /bin +MANDIR ?= /man/man1 CFLAGS = -std=c99 -Wunused-variable -Wunused-function -Wconversion @@ -18,9 +19,11 @@ tmpl: tmpl.c $(CC) -o $@ $< $(CFLAGS) install: - install -m755 tmpl -t "$(DESTDIR)$(PREFIX)$(BINDIR)" + install -m755 tmpl -D -t "$(DESTDIR)$(PREFIX)$(BINDIR)" + install -m755 tmpl.1 -D -t "$(DESTDIR)$(PREFIX)$(MANDIR)" uninstall: rm -f "$(DESTDIR)$(PREFIX)$(BINDIR)/tmpl" + rm -f "$(DESTDIR)$(PREFIX)$(MANDIR)/tmpl" .PHONY: all clean install uninstall diff --git a/README b/README @@ -0,0 +1,17 @@ +tmpl +==== + +A simple key-value templator. + +usage +----- + +tmpl is key-value templator based on the C preprocessor. Variables are defined +via line-based conditional and assignment directives, and substituted +in-line for sequences matching #{NAME}. + +The following directives are supported: + #ifeq, #ifdef, #else, #endif, #define, #default + +Templated values are read from the environment, the commandline (via -D) +or from a configuration file (provided with -C) in KEY=VALUE format. diff --git a/tmpl.1 b/tmpl.1 @@ -0,0 +1,48 @@ +.Dd Feb 17, 2024 +.Dt TMPL 1 +.Os linux + +.Sh NAME +.Nm tmpl +.Nd Simple key-value templator + +.Sh SYNOPSIS + +.Nm +.Op Fl e +.Op Fl C Ar config +.Op Fl D Ar KEY=VALUE + +.Sh DESCRIPTION + +.Nm +is key-value templator based on the C preprocessor +.Xr cpp 1 . +Variables are defined via line-based conditional and assignment directives, +and substituted in-line for sequences matching +.Em #{NAME} . +Untemplated content is read from +.Xr stdin 3 +and templated content is written to +.Xr stdout 3 . + +The following directives are supported: +.Bl -tag -offset 1c +.It #ifeq +.It #ifdef +.It #else +.It #endif +.It #define +.It #default +.El + +Templated values are read from the environment, the commandline +or a +.Ar config +file in +.Ar KEY=VALUE +format. + +.Sh AUTHORS +Written by +.An Louis Burda Aq Mt quent.burda@gmail.com .