public static void main(String[] args)
	{
		// initialize the registry
		registry = new Registry(System.getenv("KLATSCH") + File.separator + "etc" + File.separator + "registry.xml");
		
		// dispatch to the GUI if requested
		if ((args.length > 0) && args[0].equals("--gui")) {
			System.err.println("Initializing Klatsch in graphical mode.");
			self = new Main();
			KlatschGui.initialize();

	  // otherwise, no GUI
		} else {
			
			// execute a script
			if ((args.length > 0) && !args[0].startsWith("--")) {

				System.err.println("Executing script " + args[0]);
				self = new Main();
				rt   = new Runtime();
				rt.addLibrary();

				try {
					
					// set up the command-line arguments
					VString[] vArgs = new VString[args.length];
					for (int i = 0; i < args.length; ++i)
						vArgs[i] = new VString(args[i]);
					rt.set("args", new VList(vArgs));
					
					// execute the string
					VPrimitive exec = (VPrimitive) rt.get("exec");
					exec.apply(new VString(args[0]));

				} catch (EvaluationException e) {
					System.err.println(e);
					e.printStackTrace();
				}
				
		  // or enter the read-eval-print loop
			} else {
				
				System.err.println("Initializing Klatsch in interactive mode.");
				self = new Main();
				rt   = new Runtime();
				rt.addLibrary();

				boolean    noEscape = (args.length > 0) && args[0].equals("--dumb");
				LineEditor editor   = new LineEditor(new InputStreamReader(System.in), "%d> ", noEscape);

				// the actual REPL
				try {
					
					// repeat until heat death of universe
					while (true) {

						// read in a full line of input
						String buffer = editor.readLine(); 

						// process that line
						self.process(buffer.toString());
					}

				} catch (IOException e) {
					System.err.println("I/O Error: " + e);
				}
			}
		}
	}