83 lines
1.3 KiB
Markdown
83 lines
1.3 KiB
Markdown
|
|
# coin
|
||
|
|
|
||
|
|
## Description
|
||
|
|
|
||
|
|
transforms a template string to its refined version by substituting its placeholders with concrete values
|
||
|
|
|
||
|
|
|
||
|
|
## Building
|
||
|
|
|
||
|
|
### Requirements
|
||
|
|
|
||
|
|
- shell interpreter
|
||
|
|
|
||
|
|
|
||
|
|
### Instructions
|
||
|
|
|
||
|
|
- execute `tools/build`
|
||
|
|
|
||
|
|
|
||
|
|
## Installation
|
||
|
|
|
||
|
|
### Requirements
|
||
|
|
|
||
|
|
- shell interpreter
|
||
|
|
|
||
|
|
|
||
|
|
### Instructions
|
||
|
|
|
||
|
|
- (as `root`) execute `tools/install`
|
||
|
|
|
||
|
|
|
||
|
|
## Usage
|
||
|
|
|
||
|
|
### Requirements
|
||
|
|
|
||
|
|
- Python 3 interpreter
|
||
|
|
|
||
|
|
|
||
|
|
### Examples
|
||
|
|
|
||
|
|
#### basic
|
||
|
|
|
||
|
|
```
|
||
|
|
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:
|
||
|
|
|
||
|
|
```
|
||
|
|
echo '{{flowers}} are {{color}}' | coin -a 'flowers:roses' | coin -a 'color:red'
|
||
|
|
```
|
||
|
|
|
||
|
|
In some contextes curly brackets might might be reserved or not available for other reasons. This can be mitigated by using different placeholder indicators:
|
||
|
|
|
||
|
|
```
|
||
|
|
echo '<<flowers>> are <<color>>' | coin -o '<<' -c '>>' -a 'flowers:roses' -a 'color:red'
|
||
|
|
```
|
||
|
|
|
||
|
|
|
||
|
|
#### file arguments
|
||
|
|
|
||
|
|
```
|
||
|
|
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
|
||
|
|
|
||
|
|
```
|
||
|
|
echo -e "flowers: daffodills\ncolor: yellow" > /tmp/data.yaml
|
||
|
|
echo '{{flowers}} are {{color}}' | coin -d /tmp/data.yaml
|
||
|
|
|
||
|
|
# daffodills are yellow
|
||
|
|
```
|
||
|
|
|
||
|
|
|