I was writing a library for myself to help automate some really common tasks I've been doing in D for scripting from the command line. For reference, here is the code in its entirety:
module libs.script;
import std.stdio: readln;
import std.array: split;
import std.string: chomp;
import std.file: File;
//Library code for boring input processing and process invocation for command-line scripting.
export:
//Takes the args given to the program and an expected number of arguments.
//If args is lacking, it will try to grab the arguments it needs from stdin.
//Returns the arguments packed into an array, or null if malformed or missing.
string[] readInput(in string[] args, in size_t expected) {
string[] packed = args.dup;
if (args.length != expected) {
auto line = split(chomp(readln()), " ");
if (line.length == (expected - args.length))
packed ~= line;
else
packed = null;
}
return packed;
}
//Digs through the .conf file given by path_to_config for a match for name_to_match in the first column.
//Returns the rest of the row in the .conf file if a match is found, and null otherwise.
string[] readConfig (in string path_to_config, in string name_to_match) {
string[] packed = null;
auto config = File(path_to_config,"r");
while (!config.eof()) {
auto line = split(chomp(config.readln()), ":");
if (line[0] == name_to_match)
packed = line[1..$];
if (packed !is null)
break;
}
config.close(); //safety measure
return packed;
}
Now, when I try to compile this in debug mode (dmd -debug), I get this error message:
Error 42: Symbol Undefined __adDupT
script.obj(script)
Error 42: Symbol Undefined __d_arrayappendT
script.obj(script)
Error 42: Symbol Undefined _D3std5stdio4File6__dtorMFZv
script.obj(script)
Error 42: Symbol Undefined _D3std5stdio4File3eofMxFNaNdZb
script.obj(script)
Error 42: Symbol Undefined __d_framehandler
script.obj(script)
Error 42: Symbol Undefined _D3std5stdio4File5closeMFZv
script.obj(script)
Error 42: Symbol Undefined _D3std6string12__ModuleInfoZ
script.obj(script)
Error 42: Symbol Undefined _D3std5stdio12__ModuleInfoZ
OPTLINK : Warning 134: No Start Address
--- errorlevel 36
I have absolutely no idea what I did wrong here. I'm using Windows 7, if that helps at all.