Skip to content

Commit

Permalink
Config override
Browse files Browse the repository at this point in the history
  • Loading branch information
fireduck64 committed Aug 21, 2018
1 parent e40d41a commit e8aaf72
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/ConfigFile.java
Expand Up @@ -10,18 +10,32 @@
public class ConfigFile extends Config
{
private Properties props;
private String env_override_prefix;

public ConfigFile(String file_name)
throws java.io.IOException
{
props = new Properties();

props.load(new FileInputStream(file_name));

if (get("env_override_prefix") != null)
{
env_override_prefix = get("env_override_prefix");
}
}

@Override
public String get(String key)
{
return props.getProperty(key);
if (env_override_prefix != null)
{
String k = env_override_prefix + key;
if (System.getenv().containsKey(k))
{
return System.getenv().get(k);
}
}
return props.getProperty(key);
}
}

0 comments on commit e8aaf72

Please sign in to comment.