parseConfigFileSimple

Attempt to read and process the config file at path, print any error

This 'simple' overload of the more detailed parseConfigFile will attempt to read the file at path, and return a Nullable instance of it. If an error happens, either because the file isn't readable or the configuration has an issue, a message will be printed to stderr, with colors if the output is a TTY, and a null instance will be returned.

The calling code can hence just read a config file via:

int main ()
{
    auto configN = parseConfigFileSimple!Config("config.yaml");
    if (configN.isNull()) return 1; // Error path
    auto config = configN.get();
    // Rest of the program ...
}

An overload accepting CLIArgs args also exists.

  1. Nullable!T parseConfigFileSimple(string path, StrictMode strict)
  2. Nullable!T parseConfigFileSimple(CLIArgs args, StrictMode strict)
    Nullable!T
    parseConfigFileSimple
    (
    T
    )

Parameters

args CLIArgs

Command line arguments on which parse has been called

strict StrictMode

Whether the parsing should reject unknown keys in the document, warn, or ignore them (default: StrictMode.Error)

Return Value

Type: Nullable!T

An initialized Config instance if reading/parsing was successful; a null instance otherwise.

Meta