X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2FMain.java;h=8003adae5591b312b95c1d5644960cd078e869ce;hb=707b1064f56e88db0cf555a99cb4aa224484f51a;hp=2c6a7d30644f9ac38adda4386a4b7e751ff79980;hpb=74955a37f7709770c2b3b3a05f0fc1dc051864f7;p=org.ibex.core.git diff --git a/src/org/ibex/Main.java b/src/org/ibex/Main.java index 2c6a7d3..8003ada 100644 --- a/src/org/ibex/Main.java +++ b/src/org/ibex/Main.java @@ -3,6 +3,7 @@ package org.ibex; import java.net.*; import java.io.*; +import java.util.*; import org.ibex.js.*; import org.ibex.util.*; @@ -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 xwar file"); - System.err.println(" - the path to a directory to be used as an xwar"); - System.err.println(" - the http url of an xwar"); - 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++; } @@ -74,11 +90,11 @@ public class Main { 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); } });