Ultimaker/CuraEngine — pull request #55 by sshirokov (2014-02-08 11:44:21+00:00)
Title: Configuration Files

Add support for adjusting the various settings in `settings.h`/`ConfigSettings` by using an external file, in addition to the existing method of using `... -s key=val`, in a similar format.

It also adds the concept of a *"default config"*, expected at `default.cfg` in the CWD, which is read unconditionally on start before other options are applied to store default settings that differ from the compiled-in defaults in `settings.cpp`.

### New API / Constants

* `DEFAULT_CONFIG_PATH` -- The location of the default config file, set to `"default.cfg"`
* `bool ConfigSettings::readSettings(const char* path)` -- Read a config at `path`
* `bool ConfigSettings::readSettings(void)` -- Read the default config

### New Features

* The default config is read before command line options are processed
* `-c path_to_config` CLI option to specify an additional config to apply (documented in `-h` output)

There's no restriction on the number of configuration files that can be loaded. Config files are applied in the order they are specified, then top to bottom as they are read.

### Config format

The config is a list of `name=value` pairs, one per line. Blank lines are ignored. The `name` of a setting must be valid as seen by `bool ConfigSettings::setSetting(name, value)`. An invalid name causes the config load to halt with an error.

Comments begin with `#` and continue to the end of the line.

Spacing around `=` is ignored.

#### Example `default.cfg`:

```sh
## A default config for makerbot gcode
gcodeFlavor = 2 # Makerbot

# Layers
layerThickness = 270
fanFullOnLayerNr = 4

# Speeds
moveSpeed = 120
```