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.

bash cargo install yagenerator

See tests directory for an example.

Generate files given:

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

In addition implements the following custom formatters:

The documentation of the formatters can be found in 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

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

```