@@ -26,9 +26,9 @@ Do not edit this file. Edit 'docs/templates/README.md.j2' instead and run 'make
26
26
27
27
| OS | Arch | Version | |
28
28
| ------------ | ------- | --------------------- | ---- |
29
- | macOS (Darwin) | x86_64 | 1.0.3 (latest) | [ Download] ( https://github.com/busyloop/envcat/releases/latest ) |
30
- | Linux | x86_64 | 1.0.3 (latest) | [ Download] ( https://github.com/busyloop/envcat/releases/latest ) |
31
- | Linux | aarch64 | 1.0.3 (latest) | [ Download] ( https://github.com/busyloop/envcat/releases/latest ) |
29
+ | macOS (Darwin) | x86_64 | 1.1.0 (latest) | [ Download] ( https://github.com/busyloop/envcat/releases/latest ) |
30
+ | Linux | x86_64 | 1.1.0 (latest) | [ Download] ( https://github.com/busyloop/envcat/releases/latest ) |
31
+ | Linux | aarch64 | 1.1.0 (latest) | [ Download] ( https://github.com/busyloop/envcat/releases/latest ) |
32
32
33
33
#### macOS :beer :
34
34
@@ -61,7 +61,6 @@ echo "{{BIND}}:{{PORT | default('443')}} {{NAME}}" | envcat -f j2 -c PORT:?port
61
61
:bulb : See ` envcat --help ` for full syntax reference.
62
62
63
63
64
-
65
64
## Templating
66
65
67
66
With ` -f j2 ` , or when called by the name ` envtpl ` , envcat renders a jinja2 template from _ stdin_ to _ stdout_ .
@@ -126,6 +125,74 @@ echo "{% for x in FOO | split(',') %}{{x}}..{% endfor %}" | envtpl FOO # => a..
126
125
Envcat uses a [ Crystal implementation of the jinja2 template engine] ( https://straight-shoota.github.io/crinja/ ) .
127
126
Python expressions are ** not** supported.
128
127
128
+ ## Layering data from multiple sources
129
+
130
+ By default envcat reads variables only from your shell environment.
131
+ With ` -i ` you can additionally source data from YAML, JSON or TOML files.
132
+
133
+ ** Example:**
134
+
135
+ ``` bash
136
+ # Override an env-var via YAML file
137
+ $ export FOO=bar
138
+ $ echo " foo: batz" > demo.yaml
139
+ $ envcat -i env -i yaml:demo.yaml FOO
140
+ {" FOO" :" batz" }
141
+
142
+ # We can also ignore the environment
143
+ # altogether and use only file sources.
144
+ $ envcat -i yaml:foo.yaml -i json:bar.json FOO
145
+ {" FOO" :" batz" }
146
+ ```
147
+
148
+ With ` -s ` you can overwrite values directly.
149
+
150
+ ** Example:**
151
+
152
+ ``` bash
153
+ $ export FOO=bar
154
+ $ envcat -s FOO=batz HELLO
155
+ batz
156
+ ```
157
+
158
+ ` -s ` takes precedence over all other data sources.
159
+
160
+
161
+ ### Input normalization
162
+
163
+ envcat flattens the structure of data sourced via ` -i ` as follows.
164
+
165
+ Given the following YAML:
166
+
167
+ ``` yaml
168
+ # demo.yaml
169
+ employee :
170
+ name : Jane Smith
171
+ department : HR
172
+ contact :
173
+
174
+ phone : 555-123-4567
175
+ projects :
176
+ - Project A
177
+ - Project B
178
+ skills :
179
+ - Skill 1
180
+ - Skill 2
181
+ ` ` `
182
+
183
+ ` envcat -f yaml -i yaml:demo.yaml '*'` produces the following output:
184
+
185
+ ` ` ` yaml
186
+ EMPLOYEE_NAME: Jane Smith
187
+ EMPLOYEE_DEPARTMENT: HR
188
+ EMPLOYEE_CONTACT_EMAIL: [email protected]
189
+ EMPLOYEE_CONTACT_PHONE: 555-123-4567
190
+ EMPLOYEE_PROJECTS_0: Project A
191
+ EMPLOYEE_PROJECTS_1: Project B
192
+ EMPLOYEE_SKILLS_0: Skill 1
193
+ EMPLOYEE_SKILLS_1: Skill 2
194
+ ` ` `
195
+
129
196
130
197
# # Checks
131
198
@@ -156,13 +223,21 @@ For a full list of available SPEC constraints see below.
156
223
# # Synopsis
157
224
158
225
```
159
- Usage: envcat [-f etf|kv|export|j2|j2_unsafe|json|none|yaml ] [-c <VAR[:SPEC]> ..] [GLOB[:etf] ..]
226
+ Usage: envcat [ -i < SOURCE > .. ] [ -s <KEY=VALUE> .. ] [ - c <VAR[ : SPEC ] > ..] [ -f etf|kv|export|j2|j2_unsafe|json|none|yaml ] [ GLOB[ : etf ] ..]
160
227
228
+ -i, --input=SOURCE env|json: PATH |yaml: PATH |toml: PATH (default: env)
229
+ -s, --set=KEY=VALUE KEY=VALUE
161
230
-f, --format=FORMAT etf|export|j2|j2_unsafe|json|kv|none|yaml (default: json)
162
231
-c, --check=VAR[ : SPEC ] Check VAR against SPEC. Omit SPEC to check only for presence.
163
232
-h, --help Show this help
164
233
--version Print version and exit
165
234
235
+ SOURCE
236
+ env - Shell environment
237
+ json: PATH - JSON file at PATH
238
+ yaml: PATH - YAML file at PATH
239
+ toml: PATH - TOML file at PATH
240
+
166
241
FORMAT
167
242
etf Envcat Transport Format
168
243
export Shell export format
@@ -257,6 +332,9 @@ export B=world
257
332
| 1 | Invalid value (` --check ` constraint violation) |
258
333
| 3 | Syntax error (invalid argument or template) |
259
334
| 5 | Undefined variable access (e.g. your template contains ` {{FOO}} ` but $FOO is not set) |
335
+ | 7 | I/O Error |
336
+ | 11 | Parsing error |
337
+ | 255 | Bug (unhandled exception) |
260
338
261
339
## Contributing
262
340
0 commit comments