2 unstable releases
0.2.0 | Mar 25, 2019 |
---|---|
0.1.0 | Mar 19, 2019 |
#358 in Value formatting
4KB
62 lines
Envja
Performs environment variable interpolation in a Jinja2-lite syntax.
Contains both the CLI and the library component.
How to install CLI
Via cargo
cargo install envja
Simple Examples
Direct
envja direct '{% if VAL %}VAL={{VAL}}{% endif %}'
Should return empty string because VAL
env var is missing.
VAL=hello envja direct '{% if VAL %}VAL={{VAL}}{% endif %}'
Should return VAL=hello
.
Direct via STDIN
With similar set-up like in Direct:
echo -n '{% if VAL %}VAL={{VAL}}{% endif %}' | envja direct
echo -n '{% if VAL %}VAL={{VAL}}{% endif %}' | VAL=hello envja direct
Via file
With similar set-up like in Direct:
echo -n '{% if VAL %}VAL={{VAL}}{% endif %}' > test.tmpl
envja file test.tmpl
rm test.tmpl
echo -n '{% if VAL %}VAL={{VAL}}{% endif %}' > test.tmpl
VAL=hello envja file test.tmpl
rm test.tmpl
Complex Example
echo '{% if LINUX_HEADER %}#include <{{LINUX_HEADER}}>{% endif %}
int main() {
return {{ RET }};
}' > test.tmpl
LINUX_HEADER=unistd.h RET=123 envja file test.tmpl
rm test.tmpl
Should print:
#include <unistd.h>
int main() {
return 123;
}
Syntax Acceptance
If-statement
{% if ENV %}ENV value is {{ ENV }}{% endif %}
Expression
{{ ENV }}
Comments
{# comments #}
Regular text
Regular text
Dependencies
~5MB
~88K SLoC