A CLI tool for editing .env files with an intuitive interface
Project description
pyenvedit
A CLI tool for editing .env files with an intuitive interface. Edit environment variables from the command line or through an interactive TUI.
Installation
Install from PyPI:
pip install pyenvedit
Usage
Command Line Interface
Display .env file contents
pyenvedit .env
Add a new environment variable
pyenvedit .env --add API_KEY=your_api_key_here
pyenvedit .env --add DATABASE_URL=postgresql://localhost/mydb
Edit an existing environment variable
pyenvedit .env --edit API_KEY=new_api_key_value
pyenvedit .env --edit DEBUG=true
Remove an environment variable
pyenvedit .env --remove API_KEY
pyenvedit .env --remove UNUSED_VAR
Interactive TUI Mode
Launch the interactive TUI by running pyenvedit without any flags on a non-existent file:
pyenvedit myproject.env
The TUI provides:
- View: Browse all environment variables in a table
- Add: Add new variables through a modal dialog
- Edit: Edit existing variables by selecting them and clicking "Edit Selected"
- Delete: Remove variables by selecting them and clicking "Delete Selected"
- Navigation: Use arrow keys to navigate, Enter to select
Key Features
- Safe editing: Preserves comments and formatting
- Validation: Ensures variable names follow proper conventions
- Error handling: Clear error messages for invalid operations
- Cross-platform: Works on Windows, macOS, and Linux
- UTF-8 support: Handles international characters in values
Examples
Basic Usage
# Display current .env file
pyenvedit
# Add a database URL
pyenvedit --add DATABASE_URL=sqlite:///app.db
# Update an API key
pyenvedit --edit API_KEY=sk-new-key-12345
# Remove an old variable
pyenvedit --remove OLD_API_KEY
# Edit a different env file
pyenvedit config/staging.env --add REDIS_URL=redis://localhost:6379
Interactive Mode
# Launch TUI for current directory's .env
pyenvedit
# Launch TUI for specific file
pyenvedit config/production.env
File Format Support
pyenvedit works with standard .env file format:
# Comments are preserved
API_KEY=your_key_here
DATABASE_URL=postgresql://user:pass@localhost/db
DEBUG=true
# Quoted values are supported
MESSAGE="Hello, World!"
PATH='/usr/local/bin:/usr/bin'
Requirements
- Python 3.8 or higher
- textual >= 0.40.0
- click >= 8.0.0
Development
To set up for development:
git clone https://github.com/marcokotrotsos/envedit
cd envedit
pip install -e .
License
MIT License
Project details
Release history Release notifications | RSS feed
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 pyenvedit-0.2.0.tar.gz.
File metadata
- Download URL: pyenvedit-0.2.0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94d8bd0330212712330d51f73c471f278a289c4102b17ed14a9b06e76de83534
|
|
| MD5 |
5eb41808c566460d435b05748eb0ca90
|
|
| BLAKE2b-256 |
884e2f7a48259b18b93c9a68a22d72723460b52cbadf8da4d619db1550b0de94
|
File details
Details for the file pyenvedit-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pyenvedit-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
337132f26a315bbaa15ae97c21fba2df6249d4722fe1007436f326456c065a4a
|
|
| MD5 |
2c6d3f4e725529d358169faaeac5e95b
|
|
| BLAKE2b-256 |
6d23a13b165a4d25aa2795b90376f659c7473e18d1cdf880ae42eb34355a3618
|