/**
 * 
 * Sikuli runner.
 * TODO see why Sikuli may in some cases hang up and not finish, or give other exceptions seemingly randomly
 * @author sharefaith2
 *
 */
public class SikuliRunner
{
	/**
	 * The sikuli app command.
	 */
	public static String Sikuli = "/Applications/SikuliX.app/run";
	
	
	/**
	 * Blocking run of a certain .sikuli file (with optional --args)
	 * @param fileArgs
	 * @throws Exception
	 */
	public static void run(String fileArgs) throws Exception
	{
		ProcessBuilder automate = new ProcessBuilder(Sikuli, "-r", fileArgs);
		automate.redirectOutput(ProcessBuilder.Redirect.INHERIT);//output the output.
		if (0 != automate.start().waitFor()) {
			throw new Exception("automate fail");
		}
	}
}
