# `repvar` - Variable replacing, UNIX-style text filter
[](
LICENSE.txt)
[](
https://api.reuse.software/info/github.com/hoijui/repvar)
[](
https://github.com/hoijui/repvar)
[](
https://crates.io/crates/repvar)
[](
https://docs.rs/repvar)
[](
https://deps.rs/repo/github/hoijui/repvar)
[](
https://github.com/hoijui/repvar/actions)
[](
https://fabcity.hamburg)
[](
https://opensourceecology.de)
A tiny CLI tool that replaces variables of the style `${KEY}`
in text with their respective value.
It can also be used as a rust library.
For the CLI tool,
the variables can be read from the environment
or be directly supplied through CLI switches,
like `-Dkey=value`.
> **NOTE** \
> The author is a rust-newb.
> This crate probably only makes sense for himself,
> and it is not using the power of rust as should be.
> It also could probably be written in just 10 lines of code,
> using one or two regexes, not loosing any performance.
## Usage
### Simplistic
```bash
$ export KEY_A="replacement" # setting an env.-variable
$ echo 'Text ${KEY_A}.' \ # input text
| repvar --env # replacing variables
Text replacement. # output
```
### Slightly more elaborate
```bash
$ export first="the environment"
$ echo 'Variables from ${first}, ${second}, ${not_supplied} and $${quoted}.' \
| repvar --env -D"second=the CLI"
Variables from the environment, the CLI, ${not_supplied} and ${quoted}.
```
More usage info can be seen when running:
```bash
repvar --help
```
## Building
```bash
# To get a binary for your system
cargo build --release
# To get a 64bit binary that is portable to all Linux systems
run/rp/build
```
## Testing
To run unit-, doc- and integration-tests:
```bash
run/rp/test
```
## Similar projects
- More powerful string templating engine,
but very much in line with the unix philosophy as well
<https://github.com/nilsmartel/string>
## Funding
This project was funded by the European Regional Development Fund (ERDF)
in the context of the [INTERFACER Project](https://www.interfacerproject.eu/),
from August 2021 (project start)
until March 2023.
