package au.edu.mq.comp.junitGrading.commandLineUI;
import au.edu.mq.comp.common.Log;
import au.edu.mq.comp.common.OS;
import au.edu.mq.comp.common.SimpleFileIO;
import au.edu.mq.comp.junitGrading.GlobalSetting;
import au.edu.mq.comp.junitGrading.webUI.AutomarkHTTPServer;
public class AutomarkEntryPoint
{
public static String version()
{
return "(9:46p)-(Apr-24-2013)";
}
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception
{
System.out.println("Running from jar -> " + OS.pathToRunningJAR(JavaGraderDriver.class));
System.out.println("Automark version:" + AutomarkEntryPoint.version());
if(0 == args.length)
{
System.out.println("to run from commandline usage: Automark configFile");
System.out.println(" to run as server usage: Automark server <portNo> <workingDirectory>");
}
else if(3 == args.length)
{
if(true == args[0].equalsIgnoreCase("server"))
{
int port = Integer.parseInt(args[1]);
String workingDir = args[2];
AutomarkHTTPServer sparkServe = new AutomarkHTTPServer(port, workingDir);
sparkServe.run();
}
else
{
Log.error("dont know option -->" + args[0]);
}
}
else if(1 == args.length)
{
GlobalSetting.setDebugging(false);
System.out.println("going to run with config file " + args[0]);
String pathToAutomarkFile = args[0];
java.io.File automarkFile = SimpleFileIO.makeFileFromPath(pathToAutomarkFile);
if(true == automarkFile.canRead())
{
JavaGraderDriver automark = new JavaGraderDriver();
SimpleFileIO.inCurrentWorkingDirectoryCreateDirectoryName("FeedBack");
String csvOutputString = automark.run(automarkFile);
if(false == csvOutputString.isEmpty())
{
SimpleFileIO.writeStringToTextFile(csvOutputString, "Result.csv");
Log.message("Wrote output csv file to -->" + "Result.csv");
}
}
else
{
System.err.println(pathToAutomarkFile + " cannot be read or does not exist");
System.err.println("Usage: Automake automarkConfigFile");
}
}
else
{
System.out.println("dont know option..");
System.out.println("usage: Automark configFile");
System.out.println("usage: Automark server port workingDirectory");
}
}
}