Configuration file is now read in from arguments.

This commit is contained in:
Tristan B. Kildaire 2020-04-30 19:18:00 +02:00
parent 0d6b757923
commit 5204274a76
1 changed files with 17 additions and 5 deletions

View File

@ -8,6 +8,7 @@ import std.stdio : File, writeln;
import std.json : parseJSON, JSONValue;
import listeners.listener;
import listeners.types;
import std.file : exists;
unittest d
{
@ -15,15 +16,26 @@ unittest d
main();
}
void main()
void main(string[] args)
{
/* Make sure we have atleast two arguments */
if(args.length >= 2)
{
/* Get the second argument for configuration file path */
string configFilePath = args[1];
/* TODO: Change this */
string address = "0.0.0.0";
ushort port = 2222;
/* Start thhe server if the file exists, else show an error */
if(exists(configFilePath))
{
startServer(args[1]);
}
else
{
writeln("Provided server configuration file \"" ~ configFilePath ~ "\" does not exist");
}
}
/* TODO: Add usage check and arguments before this */
startServer("server.conf");
dprint("Main finished, remaining threads are keeping this open if it hangs");
}