X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2FMain.java;h=8003adae5591b312b95c1d5644960cd078e869ce;hb=2532e32f07910e63b366ac8e02e897e5314be72c;hp=ed700daa085499ba0e961acbbd6e4ff1c82ebb7a;hpb=2be4954059276cd5693de78865de16cd9965307b;p=org.ibex.core.git diff --git a/src/org/ibex/Main.java b/src/org/ibex/Main.java index ed700da..8003ada 100644 --- a/src/org/ibex/Main.java +++ b/src/org/ibex/Main.java @@ -3,10 +3,11 @@ package org.ibex; import java.net.*; import java.io.*; +import java.util.*; import org.ibex.js.*; import org.ibex.util.*; -/** Entry point for the Ibex Engine; handles splash screen, initial ibex archive loading, and argument processing */ +/** Entry point for the Ibex Engine; handles splash screen, initial xwar loading, and argument processing */ public class Main { /** @@ -26,27 +27,42 @@ public class Main { public static Picture scarImage = null; public static void printUsage() { - System.err.println("Usage: ibex [-s] [-v] [-l /] source-location [initial-template]"); + System.err.println("Usage: ibex [-lawp] [ url | file | directory ]"); System.err.println(""); - System.err.println("Options:"); - System.err.println(" -v verbose logging (required for logging on Win32)"); - System.err.println(" -s [not yet supported]"); - System.err.println(" -l [not yet supported]"); - System.err.println(""); - System.err.println("Source-location is one of the following:"); - System.err.println(" - the path to an ibex file"); - System.err.println(" - the path to a directory to be used as an ibex archive"); - System.err.println(" - the http url of an ibext archive"); - System.err.println(""); - System.err.println("Initial-template is the path of the template to load; defaults to 'main'"); + System.err.println(" -l set logging level to { debug, info (default), warn, error, silent }"); + System.err.println(" -l rpc log all XML-RPC and SOAP conversations"); + System.err.println(" -l user@host email log to user@host"); + System.err.println(" -l host:port emit log to TCP socket"); + System.err.println(" -l write log to a file on disk"); + System.err.println(" -a check assertions"); + System.err.println(" -w reserved for libibex"); + System.err.println(" -p dump profiling information [not yet supported]"); Runtime.getRuntime().exit(-1); } - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws UnknownHostException, JSExn, IOException { int startargs = 0; while (true) { if (startargs > args.length - 1) printUsage(); - else if (args[startargs].equals("-v")) Log.verbose = true; + else if (args[startargs].equals("-a")) JS.checkAssertions = true; + else if (args[startargs].equals("-l")) { + startargs++; + StringTokenizer opts = new StringTokenizer(args[startargs], ","); + while(opts.hasMoreTokens()) { + String opt = opts.nextToken(); + if (opt.indexOf('@') != -1) Log.email(opt); + else if (opt.indexOf(':') != -1) + Log.tcp(opt.substring(0, opt.indexOf(':')), + Integer.parseInt(opt.substring(opt.indexOf(':') + 1))); + else if (opt.equals("debug")) Log.level = Log.DEBUG; + else if (opt.equals("info")) Log.level = Log.INFO; + else if (opt.equals("warn")) Log.level = Log.WARN; + else if (opt.equals("error")) Log.level = Log.ERROR; + else if (opt.equals("silent")) Log.level = Log.SILENT; + else if (opt.equals("rpc")) Log.rpc = true; + else Log.file(opt); + } + } else break; startargs++; } @@ -72,13 +88,13 @@ public class Main { startupTemplate = initialTemplate; } - if (Log.on) Log.info(Main.class, "loading ibex file"); + if (Log.on) Log.info(Main.class, "loading xwar"); final Ibex ibex = new Ibex(rr); - final JS final_rr = (JS)ibex.get(""); scarImage = Picture.load((Stream)Main.builtin.get("org/ibex/builtin/scar.png"), - new Scheduler.Task() { public void perform() throws Exception { + new Scheduler.Task() { public void perform() throws JSExn, UnknownHostException { + if (Log.on) Log.info(Main.class, "invoking initial template"); ibex.resolveString(startupTemplate, false).call(new Box(), null, null, null, 1); } });