Skip to content

Siela25/envik

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

envik

A compact CLI for managing multiple .env environments per project.

The name comes from "env" + the Polish diminutive suffix "-ik" — something small and self-contained.

Status

  • [done] envik init — scans the project root for .env files, moves them into .envik/, creates default.env if none found
  • [done] envik list — lists available environments in .envik/
  • [done] envik use <name> — copies .envik/<name>.env to the active .env
  • [done] envik current — shows which environment is currently active
  • [wip] Global config and database paths — config (config.json) and the tracking database (envik.db) are currently written to CWD; the intent is to store them in OS-appropriate paths via the directories crate so state is truly global across projects
  • [planned] Backup with timestamps
  • [planned] Env file encryption
  • [planned] Sharing environments across team members
  • [planned] CI/CD integration for fetching environments remotely

Why

Managing multiple .env files (dev, staging, prod) usually means manually renaming files or maintaining ad-hoc scripts. envik handles this with a single use command that copies the right environment into place, while tracking which one is active per project.

I built this to learn Rust and solve a problem I kept running into in my own projects. It is not trying to replace direnv or dotenv-vault — it is a focused, local-first tool that does one thing.

Tech stack

  • Rust 2024 — single self-contained binary, no runtime dependency
  • clap (derive) — CLI argument parsing
  • redb — embedded key-value store; no SQL, tracks active environment per project path
  • serde + serde_json — config serialization to human-readable JSON
  • anyhow — error handling
  • colored — terminal color output

Quick start

Not published to crates.io yet. Build from source:

git clone <repo>
cd envik-cli
cargo build --release

Basic usage in a project:

# initialize envik — discovers and organizes .env files
envik init

# list available environments
envik list

# switch to an environment
envik use dev

# check which environment is currently active
envik current

Architecture

your-project/
  .envik/
    dev.env         # stored environment
    prod.env
    config.json     # optional, project-local config overrides
  .env              # active file, written by 'envik use'

envik use copies the content of .envik/<name>.env to .env and records the active environment in a redb database keyed by project path.

Config is two-layered: global defaults merged with optional per-project overrides from .envik/config.json. Local values take precedence.

Key decisions

  • redb over SQLite — no external dependency; the use case is a single key-value lookup (project path → active env name), not relational data
  • File copy, not symlinkuse writes content directly to .env so the result is transparent to tools that read .env without following symlinks

About

Simple app for managing environment variables

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages