The arguments to provide to getopt
if -h has been parsed by getopt this out parameter will indicate that
A fully filled out ConfigType struct
Only parse command line arguments struct MyConfig { @Desc("My number.") int number; @Desc("My bool.") bool toggle; } enum usage = "My program version 1.0 does things."; int main(string[] args) { import std.getopt : GetOptException; MyConfig conf; bool helpWanted = false; try { conf = initializeConfig!(MyConfig, usage)(args, helpWanted); } catch (GetOptException e) { import std.stdio : stderr; stderr.writefln("Invalid argument: %s", e.msg); return 1; } if (helpWanted) { return 0; } }
Calls getopt with the provided args array. Usually you want to first call getConfigArguments and merge the command line arguments with the config arguments. Which then get passed to this function.
The template ConfigType is the plain old data struct that describes the options that are used to generate the getopt parameter list. usage is used for the defaultGetoptPrinter for the usage description when -h is provided in the args.