Show HN: Envelope – A modern environment variable cli tool

Hey HN! I've built this cli tool to manage env variables of a project, but mostly for fun and to try out Rust and the clap crate.

I had this idea when I made a big mistake and broke some production stuff because I had a very messy .env file laying around in my project.

I was implementing new features for one of my projects and in my .env file I had the test database url commented out and the production one was not. Long story short, I applied migrations to the production database instead of my local test one and broke a lot of production APIs :')

I wanted a tool that could easily help me spot these issues before something bad happened, and so I built envelope for that reason.

Instead of a \.env(\..+)? file, I now use this tool to add variables to different configurations: dev, prod etc. and I feed them to the program I am executing on a one liner.

  $ envelope init
  $ envelope add dev db_url localhost:5432/postgres
  $ envelope add dev db_username username
  $ envelope add dev db_pwd pwd
  $ export $(envelope list dev)
  $ ./run.sh
This way I am explicitly exporting the dev environment without relying on the fact that everything is in order in my .env file (another approach would be to have a .env.dev file)

A very useful feature that I use quite a lot is the `check` command which is going to tell you which environment you have currently active

  $ export $(envelope list dev)
  $ envelope check
  > dev
I don't think this tool is going to be useful to anybody, but I wanted to share this with you in case there is someone that can make good use of it or find particular scenarios where this could be used instead of .env files, either way I had a lot of fun building it

Comments URL: https://news.ycombinator.com/item?id=40758703

Points: 31

# Comments: 12

https://github.com/mattrighetti/envelope

Creato 3mo | 22 giu 2024, 17:20:12


Accedi per aggiungere un commento