envja-cli

Crates.ioenvja-cli
lib.rsenvja-cli
version0.2.0
sourcesrc
created_at2019-03-19 16:08:04.773434
updated_at2019-03-25 14:51:37.577992
descriptionCLI for Jinja2-like env var interpolation
homepage
repository
max_upload_size
id122487
size3,609
Weiguang (guangie88)

documentation

README

Envja

Codefresh build status

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
Commit count: 0

cargo fmt