package com.yasikstudio.devrank;

import java.util.HashMap;
import java.util.Map;

import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;

import com.google.common.base.Joiner;
import com.yasikstudio.devrank.merge.DataMergeJob;
import com.yasikstudio.devrank.rank.DeveloperRankJob;

public class DevRank {
  private static Map<String, Class<?>> jobs = new HashMap<String, Class<?>>();

  static {
    jobs.put("rank", DeveloperRankJob.class);
    jobs.put("merge", DataMergeJob.class);
  }

  public static void main(String[] args) throws Exception {
    if (args.length == 0) {
      usageWithExit();
    }

    String cmd = args[0];
    if (jobs.containsKey(cmd)) {
      usageWithExit();
    }

    int length = args.length - 1;
    String[] arguments = new String[length];
    System.arraycopy(args, 1, arguments, 0, length);

    Tool job = (Tool) jobs.get(cmd).newInstance();
    System.exit(ToolRunner.run(job, args));
  }

  private static void usageWithExit() {
    String joblist = Joiner.on("|").join(jobs.keySet());
    System.out.println("Usage: hadoop jar devrank-x.x.x.jar [" + joblist + "]");
    System.exit(-1);
  }
}

@@ -659,16 +659,17 @@
     if (
+!
 jobs.con
@@ -938,16 +938,21 @@
 job, arg
+ument
 s));%0A  %7D
@@ -989,24 +989,88 @@
 ithExit() %7B%0A
+    String jarname = %22devrank-x.x.x-jar-with-dependencies.jar%22;%0A
     String j
@@ -1138,10 +1138,9 @@
 rint
-ln
+f
 (%22Us
@@ -1159,38 +1159,36 @@
 jar 
-devrank-x.x.x.jar %5B%22 +
+%25s %5B%25s%5D%5Cn%22, jarname,
  joblist
  + %22
@@ -1187,14 +1187,8 @@
 list
- + %22%5D%22
 );%0A 

Fix main of devrank-job