
Kojo - Configuration Ninja
==================================================
[](https://badge.fury.io/rb/kojo)
[](https://travis-ci.com/DannyBen/kojo)
[](https://codeclimate.com/github/DannyBen/kojo/maintainability)
Kojo helps you generate configuration files from templates, using variables
and definition files.
It is a command line utility, and it works on any text file format.
Installation
$ gem install kojo
Usage
If you prefer to learn by example, see the examples folder for several use cases. Each example subfolder contains the command to run, the relevant files, and the expected output.
Variables
Include variables in your configuration templates using this syntax:
%{varname}
- Variables can be provided through the command line, or when using
@import. - Variables from the top level will be forwarded downstream, and aggregated
with any additional variables that are defined in subsequent
@imports.
Import
Use the @import filename directive anywhere to include another file in the
resulting configuration file.
- The
@importdirective should be the only thing in the line. - The indentation will be respected when importing.
- The
filenameparameter does not have to include an extension - Kojo will use the same extension as the parent file. - The included file will be searched for relative to the file it is included in.
- Arguments can be passed down to the included template by using this syntax:
@import filename (arg: "value", arg2: "value")
The space after filename is optional.
One to Many Generation
In order to generate several configuration files that are based on the same template, you should:
- Create the configuration template, using
%{variables}and@importswhere appropriate. - Create a configuration YAML file using this syntax:
input: base-template.yml
output:
outfile1.yml:
argument1: value
argument2: value
outfile2.yml:
argument1: value
argument2: value
Compile an Entire Folder
Process a folder containing templates and @imports, and generate a mirror
output folder, with all the variables and @imports evaluated.