getConfigArguments

Creates an argument array that contains the options provided in the config file.

The resulting array contains all provided and valid options excluding ones that were provided through the command line. The template ConfigType is the plain old data struct that describes the options that are read from the config filename.

string[]
getConfigArguments
(
ConfigType
)
(
string filename
,
string[] args
)

Parameters

filename string

Filename of the config file

args string[]

Command line arguments provided through main(string[] args)

Return Value

Type: string[]

Config exclusive argument array

Examples

struct MyConfig
{
    @Desc("My cool number.")
    int number;
    @Desc("Print verbose messages.")
    bool verbose = false;
}

int main(string[] args)
{
    string[] configArgs = getConfigArguments!MyConfig("myconfig.conf", args);

    import std.stdio : writeln;
    writeln(configArgs);
}

Assume we have a myconfig.conf file that contains the following options:

; My cool number.
number=5
; Print verbose messages.
verbose=true

alling the above program without any arguments: ./myapp will print: ["--number", "5", "--verbose", "true"].

Calling the program with a given argument: ./myapp --number=12 will print: ["--verbose", "true"]. You can see that our provided --number=12 has been excluded.

Meta