#cli #ci #variable-replacement

bin+lib repvar

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

7 releases

0.1.17 Aug 8, 2021
0.1.16 Aug 8, 2021

#727 in Text processing

22 downloads per month
Used in kicad-text-injector

GPL-3.0-or-later

40KB
454 lines

repvar - Variable replacing UNIX-style text filter

License: GPL-3.0-or-later REUSE status crates.io Docs dependency status Build status

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.

Usage

A Simplisitc example:

$ export VAR_A="replacement"   # setting an env.-variable
$ echo 'Text ${VAR}.' \        # input text
    | repvar --env             # filtering with `repvar`
Text replacement.              # output

A slightly more elaborate example:

$ export first="the environment"
$ echo 'Variables from ${first}, ${second}, ${not_supplied} and $${quoted}.' \
    | repvars --env -D"second=the CLI"
Variables from the environment, the CLI, ${not_supplied} and ${quoted}.

More usage info can be seen when running:

repvars --help

Building

cargo build --release

Testing

To run the unit-tests:

cargo test

Dependencies

~3MB
~66K SLoC