# Non-sensitive values can be stored in version control
APP_NAME=EnvSpec Demo
NOT_A_SECRET="I don't care if this gets leaked"
# Blank keys will capture values from the environment
ENVIRONMENT=
SECRET_API_KEY=
If any variables were not found, you will see clear, concise errors in your logs.
# Non-sensitive values can be stored in version control
APP_NAME="EnvSpec Demo"
NOT_A_SECRET="I don't care if this gets leaked"
# Blank keys will capture values from the environment
ENVIRONMENT="staging"
SECRET_API_KEY="2d803bd451c77c3c130a4dda46cf0b22"
- No new syntax
- You already know how it works
- Comments and breaks will be preserved
- Automatically quotes values and regularizes formatting
- It's a single bash script
- Commit it to your repo
- No installer
- Runs anywhere
- Choose a different specfile; eg: you may want to keep it out of project root
- Choose a different name or location for the output dotenv file
- 0: Minimal - Only show me errors
- 1: Default - shows confirmation for each required variable
- 2: Copious - tell me every little thing
- Disable ANSI formatting in stdout
- Environment-provided values will overwrite spec-provided values.
- eg: If the spec contains
ENV=dev
, but the pipeline definesENV
asstaging
, the output.env
will containENV="staging"
- eg: If the spec contains
- Any existing
.env
file in the working dir is backed up to.env.bak
- Any existing
.env.bak
is out of luck.
- Output values are always double-quoted
- Comments and blank lines are preserved
- Extraneous whitespace is removed:
KEY = value
will becomeKEY="value"
- EnvSpec will halt in the following cases:
- If the
.envspec
file is missing - If a required variable is not found in the environment
- If a line doesn't contain a
=
, but is also not a comment
- If the
- Keys with explicit blank values, like
INTENTIONALLY_BLANK=""
, will not cause an error if not found in the environment. - If EnvSpec stops due to an error, the WIP envfile will be deleted.
- Verbose output flag
- Flags to disable automatic formatting and quoting
- More unit tests
- Missing key
=value
should throw - Flag options
- Help text terminates with 0
- Colors
- Output levels
- Loading alternate specfiles
- Writing alternate envfiles
- Missing key
- Do string processing without
sed
If you would like to help with any of the above items, please send a pull request.
Please send pull requests to add new unit tests or request optional features. This project's goals include having as few feature flags as possible, so it better be a good idea.
This software is published under the Unlicense. No rights reserved, but no warranty either. See LICENSE for terms.