Written by

Question Rubens Silva · Jul 11, 2017

dotenv: Read enviroment variables from a .dotenv or straight from your OS

You might find it useful or not. It depends on what you can imagine it to be used with, like I had to.

Either way, I created a lib that can fetch environment variables from a file or from the OS where Caché is running.

Mostly know as dotenv. Many languages have it, so why not Caché?
The usage is pretty simple:
If you want to use OS env vars exclusively, just use the method:

##class(DotEnv.Parser).FromOS()

Otherwise, if you want to specify a .env file containing your variables to complement the OS ones use the method:

##class(DotEnv.Parser).FromPath("/path/to/file")

Both methods return an %ArrayOfDataTypes containing the env variables.

Comments

Eduard Lebedyuk · Jul 11, 2017

Thank you!

Here's a method to get OS environment variable:

write $System.Util.GetEnviron(VariableName)
0
Rubens Silva  Jul 11, 2017 to Eduard Lebedyuk

Oh crap! I knew I had seen it somewhere.
EDIT: Ahh, btw... it's Util, not Utils.

0