summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2024-02-18 00:00:04 +0100
committerLouis Burda <quent.burda@gmail.com>2024-02-18 00:04:33 +0100
commit190ebaffa70bdd72dc7f761c7380b3a9e84c76e4 (patch)
treeae3fd2fbb9a9f92d30b1192c2963a23b5a0a3754
parenta128a59911dd08740da02e365238e67bd4645710 (diff)
downloadtmpl-190ebaffa70bdd72dc7f761c7380b3a9e84c76e4.tar.gz
tmpl-190ebaffa70bdd72dc7f761c7380b3a9e84c76e4.zip
Add README and manpage
-rw-r--r--Makefile5
-rw-r--r--README17
-rw-r--r--tmpl.148
3 files changed, 69 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index d83f9c2..a2abe5c 100644
--- 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
new file mode 100644
index 0000000..47c9c20
--- /dev/null
+++ 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
new file mode 100644
index 0000000..34d21e3
--- /dev/null
+++ 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 .