repvar
repvar
(short for Replace Variables)
is a CLI (Command-line Interface) 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
.
Example scenarios
Simplisitc
$ export KEY_A="replacement" # setting an env.-variable
$ echo 'Text ${KEY_A}.' \ # input text
| repvar --env # replacing variables
Text replacement. # output
Slightly more elaborate
$ 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