 
 # Configuration file
 for k, v of require(path.resolve(exports.CONFIG_DIR, 'config'))
-  if defaults[k]?
-    exports[k] ?= common.matchType(defaults[k], v)
+  setConfig(k, v)
 
 
 # Defaults
 for k, v of defaults
-  exports[k] ?= defaults[k]
+  setConfig(k, v)
 
 
 # load parameter configurations

# Environment variable
for k, v of process.env
  k = k[9..] # remove "GENIEACS_" prefix
  if defaults[k]?
    exports[k] ?= common.matchType(defaults[k], v)


# Find config dir

  TASK_PARAMETERS_BATCH_SIZE : 32
}

exports.LIBXMLJS_OPTIONS = {}


setConfig = (name, value) ->
  return true if exports[name]?

  _value = null

  if defaults[name]?
    _value = common.matchType(defaults[name], value)
  else if common.startsWith(name, 'XML_PARSE_')
    n = name[10..].toLowerCase() # libxmljs' options are lower case
    _value = common.matchType(true, value)
    exports.LIBXMLJS_OPTIONS[n] = _value

  if _value?
    exports[name] = _value
    # Save as environmnet variable to pass on to any child processes
    process.env["GENIEACS_#{name}"] = _value

  return _value?


# Command line arguments
exports.argv = []
