https://github.com/cycloidio/tmpltui
TUI to show Go template files and the rendered result side by side
https://github.com/cycloidio/tmpltui
Last synced: 4 months ago
JSON representation
TUI to show Go template files and the rendered result side by side
- Host: GitHub
- URL: https://github.com/cycloidio/tmpltui
- Owner: cycloidio
- Created: 2024-01-23T14:15:25.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-30T14:24:42.000Z (over 1 year ago)
- Last Synced: 2024-11-19T09:48:48.628Z (over 1 year ago)
- Language: Go
- Size: 2.39 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# tmpl
This is a small CLI to explore and render tmaplated files.
You can either start the TUI with the `tui` subcommand or print to stdout the rendered file with the `render` subcommand.
The TUI allows you to pick a template file and render it, the original file and the rendered result are shown side by side.
The `stack_templating.json` file contains the data that is used to render the template, you can change the filename and path with the config flag.
You can change the template delimiters by specifying in `stack_templating.json` a `left_delimiter` and a `right_delimiter` string.
## Example
A simple example configuration is in `example_cycloid.yaml`, you can change the data in `stack_templating.json` and see how the rendering changes.
## Installation
Precompiled binaries for released versions are available in the [release](https://github.com/cycloidio/tmpltui/releases) page on Github.
Example:
```bash
LATEST_RELEASE=$(curl -s https://api.github.com/repos/cycloidio/tmpltui/releases/latest | jq -r '.tag_name')
wget https://github.com/cycloidio/tmpltui/releases/download/$LATEST_RELEASE/tmpltui-$LATEST_RELEASE-linux-amd64.tar.gz
tar xf tmpltui-*.tar.gz
```
## Getting started
Get the `stack_templating.json` file that contains default Cycloid special variables.
```bash
wget https://raw.githubusercontent.com/cycloidio/tmpltui/main/stack_templating.json
```
Get an example of a template.
```bash
wget https://raw.githubusercontent.com/cycloidio/tmpltui/main/example_cycloid.yaml
```
```bash
./tmpl tui
```
From the prompt, select your `example_cycloid.yaml` template file, press `enter`, and then `f` to display it in full screen.
To print the rendered file on stdout:
```bash
tmpl render -f example_cycloid.yaml
```
## Usage
```
usage: tmpl [-h | -help] [-c | -config ] []
options:
-h, -help displays this text
-c, -config data and config used to render the template
-t, -type the type of templating, valid values are 'stacks' or 'blueprints'. default 'stacks'
commands:
render
renders the template to stdout
usage: tmpl render [-h | -help] [-f | -file ]
options:
-h, -help displays this text
-f, -file path to template file
default: .cycloid.yaml
tui
starts a tui to view the template and the rendered file side by side
```