coin/readme.md

90 lines
1.4 KiB
Markdown
Raw Normal View History

2025-07-17 14:15:04 +02:00
# coin
2025-09-22 21:44:58 +02:00
transforms a template string to its refined version by substituting its placeholders with concrete values; hence it can be used as a very basic template engine
2025-07-17 14:15:04 +02:00
## Building
### Requirements
- shell interpreter
### Instructions
- execute `tools/build`
## Installation
### Requirements
- shell interpreter
### Instructions
- (as `root`) execute `tools/install`
## Usage
### Requirements
- Python 3 interpreter
2025-07-20 18:51:52 +02:00
### Explanation
- see `coin -h`
2025-07-17 14:15:04 +02:00
### Examples
#### basic
2025-07-17 14:43:53 +02:00
```sh
2025-07-17 14:15:04 +02:00
echo '{{flowers}} are {{color}}' | coin -a 'flowers:roses' -a 'color:red'
# roses are red
```
The same result can be produced by using multiple `coin` calls:
2025-07-17 14:43:53 +02:00
```sh
2025-07-17 14:15:04 +02:00
echo '{{flowers}} are {{color}}' | coin -a 'flowers:roses' | coin -a 'color:red'
2025-07-20 18:58:30 +02:00
# roses are red
2025-07-17 14:15:04 +02:00
```
2025-09-22 21:01:17 +02:00
In some contextes curly brackets might be reserved or not available for other reasons. This can be mitigated by using different placeholder indicators:
2025-07-17 14:15:04 +02:00
2025-07-17 14:43:53 +02:00
```sh
2025-07-17 14:15:04 +02:00
echo '<<flowers>> are <<color>>' | coin -o '<<' -c '>>' -a 'flowers:roses' -a 'color:red'
2025-07-20 18:58:30 +02:00
# roses are red
2025-07-17 14:15:04 +02:00
```
#### file arguments
2025-07-17 14:43:53 +02:00
```sh
2025-07-17 14:15:04 +02:00
echo -n "cornflowers" > /tmp/flowers.txt
echo -n "blue" > /tmp/color.txt
echo '{{flowers}} are {{color}}' | coin -a 'flowers:@/tmp/flowers.txt' -a 'color:@/tmp/color.txt'
# cornflowers are blue
```
#### data file
2025-07-17 14:43:53 +02:00
```sh
2025-07-17 14:15:04 +02:00
echo -e "flowers: daffodills\ncolor: yellow" > /tmp/data.yaml
echo '{{flowers}} are {{color}}' | coin -d /tmp/data.yaml
# daffodills are yellow
```