-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
152 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,9 +26,9 @@ Do not edit this file. Edit 'docs/templates/README.md.j2' instead and run 'make | |
|
||
| OS | Arch | Version | | | ||
| ------------ | ------- | --------------------- | ---- | | ||
| macOS (Darwin) | x86_64 | 1.0.3 (latest) | [Download](https://github.com/busyloop/envcat/releases/latest) | | ||
| Linux | x86_64 | 1.0.3 (latest) | [Download](https://github.com/busyloop/envcat/releases/latest) | | ||
| Linux | aarch64 | 1.0.3 (latest) | [Download](https://github.com/busyloop/envcat/releases/latest) | | ||
| macOS (Darwin) | x86_64 | 1.1.0 (latest) | [Download](https://github.com/busyloop/envcat/releases/latest) | | ||
| Linux | x86_64 | 1.1.0 (latest) | [Download](https://github.com/busyloop/envcat/releases/latest) | | ||
| Linux | aarch64 | 1.1.0 (latest) | [Download](https://github.com/busyloop/envcat/releases/latest) | | ||
|
||
#### macOS :beer: | ||
|
||
|
@@ -60,6 +60,73 @@ echo "{{BIND}}:{{PORT | default('443')}} {{NAME}}" | envcat -f j2 -c PORT:?port | |
|
||
:bulb: See `envcat --help` for full syntax reference. | ||
|
||
## Layering data from multiple sources | ||
|
||
By default envcat reads variables only from your shell environment. | ||
With `-i` you can additionally source data from YAML, JSON or TOML files. | ||
|
||
**Example:** | ||
|
||
```bash | ||
# Override an env-var via YAML file | ||
$ export FOO=bar | ||
$ echo "foo: batz" >demo.yaml | ||
$ envcat -i env -i yaml:demo.yaml FOO | ||
{"FOO":"batz"} | ||
|
||
# We can also ignore the environment | ||
# altogether and use only file sources. | ||
$ envcat -i yaml:foo.yaml -i json:bar.json FOO | ||
{"FOO":"batz"} | ||
``` | ||
|
||
### Input normalization | ||
|
||
envcat flattens and normalizes the structure | ||
of data read from file-sources. | ||
|
||
Given the following YAML: | ||
|
||
```yaml | ||
# demo.yaml | ||
employee: | ||
name: Jane Smith | ||
department: HR | ||
contact: | ||
email: [email protected] | ||
phone: 555-123-4567 | ||
projects: | ||
- Project A | ||
- Project B | ||
skills: | ||
- Skill 1 | ||
- Skill 2 | ||
``` | ||
`envcat -f yaml -i yaml:demo.yaml '*'` will produce the following output: | ||
|
||
```yaml | ||
EMPLOYEE_NAME: Jane Smith | ||
EMPLOYEE_DEPARTMENT: HR | ||
EMPLOYEE_CONTACT_EMAIL: [email protected] | ||
EMPLOYEE_CONTACT_PHONE: 555-123-4567 | ||
EMPLOYEE_PROJECTS_0: Project A | ||
EMPLOYEE_PROJECTS_1: Project B | ||
EMPLOYEE_SKILLS_0: Skill 1 | ||
EMPLOYEE_SKILLS_1: Skill 2 | ||
``` | ||
|
||
### With `-s` you can overwrite values directly | ||
|
||
**Example:** | ||
|
||
```bash | ||
$ export FOO=bar | ||
$ envcat -s FOO=batz HELLO | ||
batz | ||
``` | ||
|
||
`-s` takes precedence over all other data sources. | ||
|
||
|
||
## Templating | ||
|
@@ -156,13 +223,21 @@ For a full list of available SPEC constraints see below. | |
## Synopsis | ||
|
||
``` | ||
Usage: envcat [-f etf|kv|export|j2|j2_unsafe|json|none|yaml] [-c <VAR[:SPEC]> ..] [GLOB[:etf] ..] | ||
Usage: envcat [-i <SOURCE> ..] [-s <KEY=VALUE> ..] [-c <VAR[:SPEC]> ..] [-f etf|kv|export|j2|j2_unsafe|json|none|yaml] [GLOB[:etf] ..] | ||
|
||
-i, --input=SOURCE env|json:PATH|yaml:PATH|toml:PATH (default: env) | ||
-s, --set=KEY=VALUE KEY=VALUE | ||
-f, --format=FORMAT etf|export|j2|j2_unsafe|json|kv|none|yaml (default: json) | ||
-c, --check=VAR[:SPEC] Check VAR against SPEC. Omit SPEC to check only for presence. | ||
-h, --help Show this help | ||
--version Print version and exit | ||
|
||
SOURCE | ||
env - Shell environment | ||
json:PATH - JSON file at PATH | ||
yaml:PATH - YAML file at PATH | ||
toml:PATH - TOML file at PATH | ||
|
||
FORMAT | ||
etf Envcat Transport Format | ||
export Shell export format | ||
|
@@ -257,6 +332,9 @@ export B=world | |
| 1 | Invalid value (`--check` constraint violation) | | ||
| 3 | Syntax error (invalid argument or template) | | ||
| 5 | Undefined variable access (e.g. your template contains `{{FOO}}` but $FOO is not set) | | ||
| 7 | I/O Error | | ||
| 11 | Parsing error | | ||
| 255 | Bug (unhandled exception) | | ||
|
||
## Contributing | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,6 +63,73 @@ echo "{{BIND}}:{{PORT | default('443')}} {{NAME}}" | envcat -f j2 -c PORT:?port | |
|
||
:bulb: See `envcat --help` for full syntax reference. | ||
|
||
## Layering data from multiple sources | ||
|
||
By default envcat reads variables only from your shell environment. | ||
With `-i` you can additionally source data from YAML, JSON or TOML files. | ||
|
||
**Example:** | ||
|
||
```bash | ||
# Override an env-var via YAML file | ||
$ export FOO=bar | ||
$ echo "foo: batz" >demo.yaml | ||
$ envcat -i env -i yaml:demo.yaml FOO | ||
{"FOO":"batz"} | ||
|
||
# We can also ignore the environment | ||
# altogether and use only file sources. | ||
$ envcat -i yaml:foo.yaml -i json:bar.json FOO | ||
{"FOO":"batz"} | ||
``` | ||
|
||
### Input normalization | ||
|
||
envcat flattens and normalizes the structure | ||
of data read from file-sources. | ||
|
||
Given the following YAML: | ||
|
||
```yaml | ||
# demo.yaml | ||
employee: | ||
name: Jane Smith | ||
department: HR | ||
contact: | ||
email: [email protected] | ||
phone: 555-123-4567 | ||
projects: | ||
- Project A | ||
- Project B | ||
skills: | ||
- Skill 1 | ||
- Skill 2 | ||
``` | ||
|
||
`envcat -f yaml -i yaml:demo.yaml '*'` will produce the following output: | ||
|
||
```yaml | ||
EMPLOYEE_NAME: Jane Smith | ||
EMPLOYEE_DEPARTMENT: HR | ||
EMPLOYEE_CONTACT_EMAIL: [email protected] | ||
EMPLOYEE_CONTACT_PHONE: 555-123-4567 | ||
EMPLOYEE_PROJECTS_0: Project A | ||
EMPLOYEE_PROJECTS_1: Project B | ||
EMPLOYEE_SKILLS_0: Skill 1 | ||
EMPLOYEE_SKILLS_1: Skill 2 | ||
``` | ||
|
||
### With `-s` you can overwrite values directly | ||
|
||
**Example:** | ||
|
||
```bash | ||
$ export FOO=bar | ||
$ envcat -s FOO=batz HELLO | ||
batz | ||
``` | ||
|
||
`-s` takes precedence over all other data sources. | ||
|
||
|
||
## Templating | ||
|
@@ -208,6 +275,9 @@ export B=world | |
| 1 | Invalid value (`--check` constraint violation) | | ||
| 3 | Syntax error (invalid argument or template) | | ||
| 5 | Undefined variable access (e.g. your template contains `{{FOO}}` but $FOO is not set) | | ||
| 7 | I/O Error | | ||
| 11 | Parsing error | | ||
| 255 | Bug (unhandled exception) | | ||
|
||
## Contributing | ||
|
||
|