public static void main(String... args) throws Exception {
    if (args.length == 0) {
      printHelp();
      return;
    }

    DependencyGraph graph;

    switch (args[0]) {
      case "print":
        graph = loadGraphs(1, args);
        System.out.println(prettyFormat(graph));
        break;
      case "findCycle":
        graph = loadGraphs(1, args);
        List<Dependency> cycle = graph.findCycle();
        if (cycle == null) {
          System.out.println("no deadlock found");
        } else {
          System.out.println("deadlocked threads: \n" + cycle);
        }
        break;
      case "findImpasse":
        graph = loadGraphs(1, args);
        graph = graph.findLongestCallChain();
        if (graph == null) {
          System.out.println("no long call chain could be found!");
        } else {
          System.out.println("longest call chain: \n" + prettyFormat(graph));
        }
        break;
      case "findObject":
        graph = loadGraphs(2, args);
        List<DependencyGraph> graphs = graph.findDependenciesWith(args[1]);
        if (graphs.isEmpty()) {
          System.out.println(
              "thread not found! Try using the print command to see all threads and locate the name of the one you're interested in?");
        } else {
          int numGraphs = graphs.size();
          int i = 0;
          System.out.println("findObject \"" + args[1] + "\"\n\n");
          for (DependencyGraph g : graphs) {
            i += 1;
            System.out.println("graph " + i + " of " + numGraphs + ":");
            System.out.println(prettyFormat(sortDependencies(g.getEdges())));
            if (i < numGraphs) {
              System.out.println("\n\n\n");
            }
          }
        }
        break;
      default:
        printHelp();
        break;
    }
  }