dotenvk
A pragmatic CLI tool for managing .env files with a focus on simplicity, security, and reliability.
Overview
dotenvk provides a straightforward command-line interface for editing environment files. Built with Rust for performance and safety, it handles common tasks like setting variables, generating secure passwords, and exporting configurations.
Installation
Or build from source:
Usage
Basic Commands
Set environment variables:
Remove variables:
List all keys:
Password Generation
Generate secure random passwords:
# Basic 32-character password (letters only)
# Include numbers and symbols
# Generate XKCD-style passphrase (requires xkcdpass)
Export Formats
Export as bash script:
# or
Export as JSON:
Working with Different Files
By default, dotenvk operates on .env in the current directory. Use -f or --file to specify a different file:
Features
- Preserves file structure: Maintains comments, empty lines, and formatting
- Safe updates: Only modifies targeted key-value pairs
- Secure passwords: Generates cryptographically secure random passwords
- Multiple export formats: Bash and JSON output for integration with other tools
- Simple interface: Clear, predictable commands that do one thing well
Philosophy
This tool embodies a practical approach to software development:
- Solve real problems: Managing environment files is a common task that deserves a dedicated tool
- Keep it simple: No complex configuration or unnecessary features
- Be reliable: Written in Rust for memory safety and consistent behavior
- Respect existing work: Preserves file formatting and comments
- Security matters: Provides secure password generation out of the box
Examples
Development Setup
# Set up a new project
# Export for local development
Production Deployment
# Generate secure production credentials
# Export as JSON for container orchestration
Password Rotation
# Rotate all password fields
Contributing
Contributions are welcome. This project values:
- Clear, maintainable code
- Comprehensive testing
- Thoughtful documentation
- Backwards compatibility
Please ensure all tests pass and add new tests for any new functionality.
License
MIT License - see LICENSE file for details.
Acknowledgments
Built with excellent Rust crates:
clapfor CLI parsinganyhowfor error handlingserdefor JSON serializationrandfor secure random generation