commandbox-modules/commandbox-dotenv

Ability to reuse variables in other declarations

lmajano opened this issue · 2 comments

By nature the normal java properties files API does NOT allow you to reuse variables in other declarations. Example:

DB_HOST=localhost
DB_CONNECTIONSTRING=jdbc:mysql://${DB_HOST}:3306/fluentapi?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&useLegacyDatetimeCode=true

This is extremely useful to create compose variables especially for reuse. However, you will need a new jar file to process these replacements. This can be used using apache commons or just a post-processor in cfml which can go over each key value and process them for replacements.

Should this be implemented in this library or in the underlying propertyFile lib which is what you use directly in the

propertyfile show

command. Furthermore, should the replacements only replace other keys in the same file, or ANY env vars that exist?

a Plus 1 from me, I do not think the underlying property lib should change and any replacements should take place at the time of execution so

DB_HOST=localhost
DB_CONNECTIONSTRING=jdbc:mysql://${DB_HOST}:3306/fluentapi
echo DB_CONNECTIONSTRING -> jdbc:mysql://localhost:3306/fluentapi
DB_HOST=192.168.0.1
echo DB_CONNECTIONSTRING -> jdbc:mysql://localhost:3306/fluentapi