public void ParseInput()
{
string cmd;
string msg;
string output;
while (running)
{
string input = Console.ReadLine();
if (input == null)
continue;
cmd = input.Split(' ')[0];
if (input.Split(' ').Length > 1)
msg = input.Substring(input.IndexOf(' ')).Trim();
else
msg = "";
try
{
switch (cmd)
{
case "help":
output = "Commands that the console can use: \n";
try
{
foreach (Command command in Command.all.All())
{
if (command.ConsoleSupport)
{
output += command.Name + ", ";
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
output = output.Remove(output.Length - 2);
Console.WriteLine(output);
break;
default:
Command runCmd = Command.all.Find(cmd);
if (runCmd != null)
{
if (runCmd.ConsoleSupport)
{
runCmd.Use(msg);
}
else
{
Console.WriteLine("This command is not supported by the console!");
}
}
else
{
Console.WriteLine("No such command!");
}
break;
}
}
catch (Exception e)
{
Logger.Log(e.Message, LogType.ErrorMessage);
}
//Thread.Sleep(10);
}
}