tompl

Crates.iotompl
lib.rstompl
version0.0.1
sourcesrc
created_at2023-03-24 08:40:23.793076
updated_at2023-03-24 08:40:23.793076
descriptioncli utility for rendering templates with toml args
homepage
repositoryhttps://github.com/semichkin/tompl
max_upload_size
id819121
size20,919
Булат (semichkin)

documentation

README

CLI Utility for Rendering Templates with TOML Args

This is a CLI utility written in Rust that allows you to render templates using args specified in a TOML file. The tool uses the clap and handlebars libraries for command line argument parsing and template rendering respectively.

Installation

To use this tool, you need to have Rust installed on your system. You can then install the tool using cargo, Rust's package manager.

cargo install tompl

Usage

tompl render --input ./path/to/config.toml --output ./out/rendered.txt

TOML File Format

The TOML file should have the following format:

template = "./path/to/template.txt"

[params]
param1 = "value1"
nparam2 = "value2"
user = "{{env.USER}}"
  • template: The path to the template file that you want to render.
  • params: A table containing the arguments that you want to pass to the template.

You can use the env parameter in the params table to access environment variables.

Example

Assuming that the config.toml file has the following contents:

template = "./template.txt"

[params]
name = "John"
age = 30

And the template.txt file has the following contents:

Hello, {{name}}!
You are {{age}} years old.
Environment variables:
{{#each env}}
- {{@key}}: {{this}}
{{/each}}

The above command will render the template using the arguments specified in the TOML file and write the output to the output.txt file

Commit count: 0

cargo fmt