public static void main(String args[]) {
    java.util.List printList = new ArrayList();
    String board = "minicommand2";
    String midictrlDir = null;
    int i;
    for (i = 0; i < args.length; i++) {
      if (args[i].equals("--board")) {
        board = args[i+1];
        i++;
      } else if (args[i].equals("--dir")) {
        midictrlDir = args[i+1];
        i++;
      } else {
        break;
      }
    }
    System.out.println("dir: " + midictrlDir);
    Preferences.initBoards(midictrlDir);
    Preferences.set("board", board);

    if (args.length > i) {
      String outputFile = args[i];
      i++;
      File output = new File(outputFile);
      String dir = output.getParent();
      String name = output.getName();
      String program = "";
      try {
        for (; i < args.length; i++) {
          program += readFileAsString(args[i]);
        }

        String hardwarePath = (midictrlDir != null ? midictrlDir : System.getProperty("user.dir")) +
          File.separator + "hardware";
        Target target = new Target(hardwarePath  + File.separator + "cores",
                                   Preferences.get("boards." + Preferences.get("board") + ".build.core"));
        PdePreprocessor preproc = new PdePreprocessor();
        preproc.write(program, dir, name, new String[] { }, target);
        for (String s : preproc.getExtraImports()) {
          System.out.println("import: " + s);
        }
        
      } catch (Exception e) {
        e.printStackTrace();
      }
      
    }
  }