public static void main(String[] args) {
		TextDebugger debugger;
		int port = -1;

		int i = 0;
		// parse options (i.e. starting with "-")
		while (i < args.length && args[i].startsWith("-")) {
			switch (args[i]) {
			case "-attach":
				try {
					port = Integer.parseInt(args[++i]);
				} catch (NumberFormatException e) {
					port = DEFAULT_PORT;
				}
				break;

			// TODO deal with other options

			default:
				System.err.println("Unknown option: " + args[i]);
				i++;
			}
		}

		if (port >= 0) {
			// attach to vm, which takes care of args
			debugger = new TextDebugger(port);
			debugger.ui();
		} else if (i < args.length) {
			// forward arguments
			final String[] arg = Arrays.copyOfRange(args, i, args.length);
			// launch
			debugger = new TextDebugger(arg);
			debugger.ui();
		} else {
			System.err.println("Could not start debugger.");
		}
	}