python-dotenv icon indicating copy to clipboard operation
python-dotenv copied to clipboard

Feature Request: Generating .env.example file from a .env file

Open ShivKJ opened this issue 2 years ago • 4 comments

Hi,

Sometimes we can not share .env file. However it would be useful if we could generate a .env.example from it which contains all the comments and keys name in it. For example, suppose .env has the following content,

# this is comment
API_SECRET_KEY=some-value

Then generated .env.example file has the following content,

# this is comment
API_SECRET_KEY=

It would be useful if a CLI command is provided for it.

Thanks

ShivKJ avatar Aug 31 '21 05:08 ShivKJ

I'll work on this soon.

ethsanders avatar Nov 09 '21 16:11 ethsanders

I just made a function that does this, but I still have to incorporate it into the cli. Will do it tonight.

ethsanders avatar Nov 09 '21 16:11 ethsanders

this is comment

API_SECRET_KEY=some-value

Thebaldguy15 avatar Jun 04 '22 03:06 Thebaldguy15

Something cool about an .env.example file is that it can not only be used for human reference purposes, but also to facilitate an opt-in programmatic safety feature. The example file can be shipped with an application, then read at runtime and used to establish a list of the names of variables that must be defined. See the dotenv module in Deno's standard library: https://deno.land/[email protected]/dotenv#safe-mode

frou avatar Jul 02 '22 19:07 frou