env-check-utils
env-check-utils is a Python package that helps you inspect and manage your environment variables and .env files with ease.
It provides commands to validate .env files against a schema, auto-generate schemas, find unused variables, and scan code directories for environment variable usage.
Installation
Install the package from PyPI:
pip install env-check-utils
Usage
Once installed, you can run it from the command line using:
env-check [OPTIONS]
Features
Here are all the available options and their descriptions:
Validate .env file against a schema:
env-check --schema path/to/schema.json
Validates your
.envfile against a provided JSON schema. Ensures that required environment variables exist and have the correct type/format.Auto-generate a schema.json from your .env file:
env-check --generate-schema
Scans your
.envfile and generates aschema.jsonautomatically based on the variables found. Useful when starting a new project or documenting existing variables.Find unused environment variables:
env-check --check-unused
Checks for environment variables present in your
.envfile but not used anywhere in your project. Helps keep your environment files clean and free from unnecessary variables.Scan a specific code directory for environment variable usage:
env-check --path path/to/code
Scans the given directory for usage of environment variables. Useful for identifying where variables are referenced in your codebase.
Examples
Example 1: Validate .env with a schema:
env-check --schema config/schema.json
Example 2: Auto-generate schema from .env:
env-check --generate-schema
Example 3: Find unused variables:
env-check --check-unused
Example 4: Scan a project folder:
env-check --path ./src