Yet another generator

Rust application, if you have a set of structured data and need to generated a bunch of arbitrary types of files from it, this tool can help you to save some time. Is a text generation tool, not a code generation one, the difference is subtle but important. It has no knowledge about the semantics of whatever is generating, for the application everything is text.

Is recommended to first read the tiny template documentation in order to understand what that brights to the table.

Can be installed directly with cargo:

bash cargo install yagenerator

Examples

See the examples:

Details

Generate files given:

Example of use:

bash yagenerator -d data.yaml -c template_config.yaml

It works by passing the data in the data file "as it is" and with the same structure to the template(s). The template syntax must conform with the requirements of the TinyTemplate rust crate.

It uses the unescaped formatter and in addition implements the following custom value formatters:

The documentation of the formatters can be found in the Inflector crate

Data File

The data file can be in json or yaml format, is a hashmap (a.k.a dictionary) were each key must be a string, and will serve as the data ID. The values can be arbitrary json or yaml data, and will be passed as is to the templates.

Template Configuration file

Is a list/array of objects with a well defined schema

Required field per configuration :

Simplified Schema

yaml $id: http://example.com/example.json $schema: http://json-schema.org/draft-07/schema title: The root schema type: array additionalItems: true default: [] items: $id: '#/items' anyOf: - $id: '#/items/anyOf/0' additionalProperties: true title: The first anyOf schema type: object properties: data_to_use_id: $id: '#/items/anyOf/0/properties/data_to_use_id' default: '' title: The data_to_use_id schema type: string destination_path: $id: '#/items/anyOf/0/properties/destination_path' default: '' title: The destination_path schema type: string enabled: $id: '#/items/anyOf/0/properties/enabled' default: false title: The enabled schema type: boolean file_path: $id: '#/items/anyOf/0/properties/file_path' default: '' title: The file_path schema type: string operation: $id: '#/items/anyOf/0/properties/operation' default: '' title: The operation schema type: string required: - data_to_use_id - file_path - destination_path - operation - enabled

Detailed Schema

```yaml $id: http://example.com/example.json $schema: http://json-schema.org/draft-07/schema additionalItems: true default: [] description: The root schema comprises the entire JSON document. examples: - - datatouseid: IODevice destinationpath: /tmp/IODevice.hpp enabled: true filepath: ./tests/templates/Interface.hpp.txt operation: Create - datatouseid: TimeDate destinationpath: /tmp/TimeDate.h enabled: true filepath: ./tests/templates/Class.h.txt operation: Create items: $id: '#/items' anyOf: - $id: '#/items/anyOf/0' additionalProperties: true default: {} description: An explanation about the purpose of this instance. examples: - datatouseid: IODevice destinationpath: /tmp/IODevice.hpp enabled: true filepath: ./tests/templates/Interface.hpp.txt operation: Create properties: datatouseid: $id: '#/items/anyOf/0/properties/datatouseid' default: '' description: An explanation about the purpose of this instance. examples: - IODevice title: The datatouseid schema type: string destinationpath: $id: '#/items/anyOf/0/properties/destinationpath' default: '' description: An explanation about the purpose of this instance. examples: - /tmp/IODevice.hpp title: The destinationpath schema type: string enabled: $id: '#/items/anyOf/0/properties/enabled' default: false description: An explanation about the purpose of this instance. examples: - true title: The enabled schema type: boolean filepath: $id: '#/items/anyOf/0/properties/filepath' default: '' description: An explanation about the purpose of this instance. examples: - ./tests/templates/Interface.hpp.txt title: The filepath schema type: string operation: $id: '#/items/anyOf/0/properties/operation' default: '' description: An explanation about the purpose of this instance. examples: - Create title: The operation schema type: string required: - datatouseid - filepath - destination_path - operation - enabled title: The first anyOf schema type: object title: The root schema type: array

```