2

I search for a tool that is / can:

  • gratis
  • free from dependencies (no scripting language interpreter needed, ...)
  • preferably a single binary
  • run on Linux, optionally Windows
  • traverse a (sub)directory structure, processing all files with a certain extension
  • replace all placeholders with their value that it retrieves from a structured file (one of json, xml, key=value or CSV)
  • write output to a file with identical filename, but extension removed
  • preferably open source and actively maintained

The utility could be run like this:

pt /var/opt/configfiles .template values.properties

One template could be named /var/opt/configfiles/fooapp/basic.conf.template with this content:

Say hello to ${Name}

Value.properties could be structured like this:

Name=me
Age=18

After the tool finished I would have a basic.conf.

I know this can be done using sed or awk. I could also write this myself in golang but both approaches are not what I'm looking for.

  • 1
    I don't know if a ready-to-use-tool exists with your very specific needs ... But can you explain, why these approaches (some lines of scripting) are not what you're looking for ? – pLumo Aug 2 '18 at 5:47
  • 1
    @RoVo two main reasons: personal preferences and the optional requirement of cross platform support. In case you can offer a script: depending on its implementation this could become an acceptable solution – Marged Aug 2 '18 at 5:52
  • 1
    Python would be cross-platform. Windows 10 can run bash script too when installed... This can be a two-liner bash script. – pLumo Aug 2 '18 at 5:53
  • 1
    @RoVo the company I work at has no python installed on Linux and I don't want to install a number of dependencies. On Windows it is unthinkable to install Python or a bash equivalent. We once had cygwin but it had to be removed and yet we have only Windows 7 – Marged Aug 2 '18 at 5:55
1

This utility seems to offer much of what I am looking for: https://github.com/gomatic/renderizer

It can not do this on its own:

  • traverse directories
  • create output files with a name that excludes the template extension

Its value list file can only be yaml, but this is no real problem

  • 1
    It is acceptable, and helpful, to accept your own answer. Doing so will help others in future. – Mawg Oct 3 '18 at 9:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.