New and very basic template replacement program released

Yesterday the first release of my new console application, BogBat v0.1.0 was released.

I wanted a program to replace templates (or placeholders) in a text file with values from a data file. I didn't need anything fancy such as loops, conditionals, built in text processing functions or white space control. Only simple replacement was needed. And the name, well it's the Bog Basic template program.

The reason I wanted this program was to help automate some program builds by automatically updating version numbers and dates in source files.

To be honest I'd started writing this program in a private GitHub repo in 2023 and forgotten all about it. Upon stumbling across it the other day I decided to finish it and make the repo public.

Anyhow, here it is. All the usual warnings about early release code apply: bugs likely, command line and functionality subject to change across v0.x releases.

The program takes two input files, one containing the templated text and another containing key/value pairs, with values separated from keys using the equals sign. By default, a template has the form {{key}} where key is the key of a value in the data file. Templates are replaced by the values associated with the keys and the result is written to an output file. The {{ and }} template delimiters can be changed using a command line option.

The BogBat page on delphidabbler.com provides basic information on how to use the command line. Detailed help is accessed from the command line. Enter BogBat --help and watch the help scroll by. Since the help is written to stderr, not stdout, it can't easily be piped to filters like more. If you want to get the help in a text file do BogBat --help 2>help.txt. I reckon I'll change this to send help text to stdout in a future release.

➣ Download the v0.1.0 release from GitHub.

BogBat was used as part of its own build process, to make the program's version resource easy to update. Version numbers etc are stored in VERSION (the data file) and the templated version information resource in VersionInfo.rc.template (the template file).  BogBat is used in a Delphi build event to generate a .rc file that is compiled and linked before deleting the .rc file. The following image illustrates.

Comments

Popular posts from this blog

Initialising dynamic arrays

Deleting elements from a dynamic array

New Array Utilities Library Unit released