readConfiguration

Reads a configuration data from a config file and command-line arguments.

Command-line arguments will override config file entries. Config file will override defaults. Only fields marked with @cli and/or @cfg UDA will be updated, any other symbols will be ignored.

Configuration file location will be checked in this order: - current working directory - same folder as the binary - $XDG_CONFIG_HOME/appname.cfg (Posix) or %LOCALAPPDATA%/appname.cfg (Windows)

string[]
readConfiguration
(
S
)
(
ref S dst
)

Parameters

dst S

struct instance which will store configuration data and defines how it should be read

Return Value

Type: string[]

CLI argument array with processed flags removed

Examples

void example ()
{
    struct S
    {
        @cli
        int value;
        @cli("flag|f") @cfg("flag")
        string anothervalue;

        void finalizeConfig () { }
    }

    S s;
    readConfiguration(s);
}

Meta