A simple CLI tool to generate .env.sample files from existing .env files, preserving comments and empty lines.
Project description
Generate-Env-Sample
A simple CLI tool to generate .env.sample files from existing .env files. This tool reads your .env file, preserves comments and empty lines, and creates a sample file with keys but without values.
Features
- Preserves comments and empty lines from the original
.envfile. - Generates a clean
.env.samplewith keys set to empty values. - Handles encoding issues, permissions, and file existence gracefully.
- Built with Python and Typer for a smooth CLI experience.
Installation
You can install using one of the following methods:
- Using pipx:
pipx install generate-env-sample
- Using uv:
uv tool install generate-env-sample
- Run directly with pipx:
pipx run generate-env-sample
- Run directly with uvx:
uvx generate-env-sample
Prerequisites
- Python 3.11 or higher
Build Instructions
This project uses uv for management. To build the project, follow these steps:
-
Install
uvby following the uv documentation. -
Clone the repository:
git clone https://github.com/heshinth/generate-env-sample.git cd generate-env-sample
-
Sync the project dependencies using uv sync:
uv sync
Usage
Run the tool from the command line:
generate-env-sample
Options
--file: Specify the.envfile to read from (default:.env)--sample: Specify the output.env.samplefile (default:.env.sample)
Examples
-
Generate
.env.samplefrom the default.env:generate-env-sample
-
Use a custom
.envfile:generate-env-sample --file myenv.env --sample myenv.sample
-
Get help:
generate-env-sample --help
Example Input/Output
Given a .env file like:
# Database configuration
DB_HOST=localhost
DB_PORT=5432
# API keys
API_KEY=your_secret_key
The generated .env.sample will be:
# Database configuration
DB_HOST=
DB_PORT=
# API keys
API_KEY=
Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file generate_env_sample-0.1.2.tar.gz.
File metadata
- Download URL: generate_env_sample-0.1.2.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
614982ac119790b1749afd18cbb83f4ea4beb09c11ceb3d93afaa8676692822b
|
|
| MD5 |
f8063f1db8ca2d838681e404930dadb1
|
|
| BLAKE2b-256 |
a1bf177145d2688439d6d3cc9d27853627c854786fbeb8642aa6f2f4e2261f3a
|
File details
Details for the file generate_env_sample-0.1.2-py3-none-any.whl.
File metadata
- Download URL: generate_env_sample-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d87caf07027d4d02d0ca77a8ca5699f21f486284bd58ec37ef90cf6ff7c3f147
|
|
| MD5 |
1dad67e8e1e5f188b65dc9f5615d2ba6
|
|
| BLAKE2b-256 |
cf6f56abf3a77ed2d1d50abd9ff0bbcb07bcc03c0ff514eb3cd8868c96be9e63
|