allow to read environment variables as config parameters

Environment variables must be prefixed with winix_ to be loaded by winix.
The winix_ prefix is then removed and the key value converted to lowercase.

Sample:
evn WINIX_MY_OPTION=TEST123test winix -c config_file

This will add my_option to the config with value TEST123test.
Environment variables are read last so they will overwrite the values
from the configuration files.
This commit is contained in:
2022-04-16 21:50:23 +02:00
parent 4f8b5e649a
commit 64e5114947
3 changed files with 82 additions and 9 deletions

View File

@@ -95,8 +95,6 @@ bool Config::ReadConfig(const std::wstring & config_file)
if( status == pt::SpaceParser::ok )
{
AssignValues();
SetAdditionalVariables();
return true;
}
else
@@ -107,6 +105,12 @@ bool Config::ReadConfig(const std::wstring & config_file)
}
void Config::AssignValuesFromSpace()
{
AssignValues();
SetAdditionalVariables();
}
void Config::AssignValues()

View File

@@ -854,6 +854,8 @@ public:
Config();
bool ReadConfig(const std::wstring & config_file);
void AssignValuesFromSpace();
/*
*