[!NOTE]
Dotenvx team made vscode plugin to do the same thing -> https://marketplace.visualstudio.com/items?itemName=dotenv.dotenvx-vscode&ssr=false#overview
dotenvx-interactive-cli
A powerful CLI tool for managing your .env files with dotenvx. Built with @effect/cli, this tool provides both command-line and interactive interfaces for encrypting and decrypting environment files, as well as setting up precommit hooks.
Why?
This tool was created to simplify the process of working with dotenvx encryption and decryption. Whether you prefer command-line efficiency or interactive guidance, you can quickly:
- Encrypt or decrypt .env files via direct commands or interactive menus
- Work with all files at once or target specific .env files
- Avoid typing lengthy dotenvx commands manually
- Set up precommit hooks with a single command
- Integrate seamlessly into CI/CD pipelines and scripts
Prerequisites
- Node.js (v16 or higher)
- dotenvx must be installed globally (
npm install -g @dotenvx/dotenvx)
Installation
You can install this package globally:
npm install -g dotenvx-interactive-cli
Or use it directly with npx:
npx dotenvx-interactive-cli
Features
- 🔒 Encrypt .env files - Command-line or interactive file selection
- 🔓 Decrypt .env files - Batch or targeted decryption
- 🪝 Precommit hook installation - One-command setup
- ⚡ Built on @effect/cli - Modern, type-safe CLI framework
- 🎯 Hybrid interface - Direct commands, interactive selection, wizard, or help-guided
- 🗂️ Interactive file selection - Beautiful checkbox interface when no files specified
- 🔍 Smart file detection - Automatically finds .env files (excludes .keys and .vault)
- ✨ Professional CLI features - Help, version, completions, and more
- 🛡️ Robust error handling - Clear error messages and graceful failures
Usage
Command Line Interface
Navigate to your project directory and use any of these commands:
Quick Actions
dotenvx-interactive-cli encrypt
dotenvx-interactive-cli decrypt
dotenvx-interactive-cli precommit
Target Specific Files
dotenvx-interactive-cli encrypt .env .env.production
dotenvx-interactive-cli decrypt .env.development
Interactive File Selection
dotenvx-interactive-cli encrypt
dotenvx-interactive-cli decrypt
Get Help and Information
dotenvx-interactive-cli --help
dotenvx-interactive-cli encrypt --help
dotenvx-interactive-cli --version
Interactive Mode
dotenvx-interactive-cli --wizard
dotenvx-interactive-cli
Shell Completions
dotenvx-interactive-cli --completions bash
dotenvx-interactive-cli --completions zsh
dotenvx-interactive-cli --completions fish
source <(dotenvx-interactive-cli --completions bash)
NPX Usage
All commands work with npx as well:
npx dotenvx-interactive-cli encrypt .env
npx dotenvx-interactive-cli --wizard
npx dotenvx-interactive-cli --help
Requirements
- A
.env.keys file must be present in your project directory
- dotenvx must be installed globally
Examples
Basic Workflow
dotenvx-interactive-cli encrypt
dotenvx-interactive-cli precommit
dotenvx-interactive-cli decrypt
Quick Commands (No Interaction)
dotenvx-interactive-cli encrypt .env .env.production
dotenvx-interactive-cli decrypt .env.development
CI/CD Integration
npx dotenvx-interactive-cli decrypt .env.production
Development Workflow
dotenvx-interactive-cli --wizard
dotenvx-interactive-cli encrypt --help
Migration from v0.3.x
If you're upgrading from the previous interactive-only version:
- Old:
dotenvx-interactive-cli (interactive menu only)
- New:
dotenvx-interactive-cli [command] (direct commands with fallback to guidance)
The tool now supports both approaches - you can use direct commands for scripting or run without arguments to see available options.
License
MIT
Contributing
Contributions, issues, and feature requests are welcome!