Esempio n. 1
0
 public static final void usageAndExit(String[] expectedArgs) {
   String clazz = threadRootClass();
   StringBuilder b = new StringBuilder();
   b.append("USAGE: ").append(clazz).append(" ");
   for (String arg : expectedArgs) {
     b.append(arg).append(" ");
   }
   System.out.println(b.toString());
   System.exit(ExitCode.INVALID_ARGUMENTS.code);
 }
Esempio n. 2
0
 private static final void dumpOptions(Map<String, String> options) {
   StringBuilder b = new StringBuilder();
   for (String key : options.keySet()) {
     b.append("--").append(key).append(" \"").append(options.get(key)).append("\" \\\n");
   }
   try {
     File f = touch("options");
     if (f != null) {
       FileWriter w = new FileWriter(f);
       w.write(b.toString());
       w.close();
     }
   } catch (IOException e) {
     log.warn(LOG_TAG, "Could not write options file");
   }
 }
Esempio n. 3
0
 public static final void usageAndExit(Map<String, String[]> argToFlagsMap) {
   String clazz = threadRootClass();
   StringBuilder b = new StringBuilder();
   b.append("USAGE: ").append(clazz).append("\n\t");
   for (String arg : argToFlagsMap.keySet()) {
     String[] flags = argToFlagsMap.get(arg);
     if (flags == null || flags.length == 0) {
       throw new IllegalArgumentException("No flags registered for arg: " + arg);
     }
     b.append("{");
     for (int i = 0; i < flags.length - 1; i++) {
       b.append(flags[i]).append(",");
     }
     b.append(flags[flags.length - 1]).append("}");
   }
   System.out.println(b.toString());
   System.exit(ExitCode.INVALID_ARGUMENTS.code);
 }