private static void buildHelpMsg(String cmd, StringBuilder builder) {
    RouterCmdUsageInfos routerUsageInfo = ADMIN_USAGE.get(cmd);

    if (routerUsageInfo == null) {
      return;
    }
    builder.append("[").append(cmd).append("]\n");

    if (!routerUsageInfo.helpInfos.isEmpty()) {
      builder.append("\t Description: \n");
      for (String helpInfo : routerUsageInfo.helpInfos) {
        builder.append("\t\t").append(helpInfo).append("\n\n");
      }
    }

    if (!routerUsageInfo.usageInfos.isEmpty()) {
      builder.append("\t UsageInfos: \n");
      for (UsageInfo usageInfo : routerUsageInfo.usageInfos) {
        builder.append("\t\t").append(usageInfo.args)
            .append(": ")
            .append("\n\t\t")
            .append(usageInfo.help).append("\n\n");
      }
    }

    if (MapUtils.isNotEmpty(routerUsageInfo.examples)) {
      builder.append("\t Examples: \n");
      int count = 1;
      for (Map.Entry<String, List<String>> example : routerUsageInfo.examples.entrySet()) {

        String keyCmd = example.getKey();
        builder.append("\t\t")
            .append("Cmd:").append(count)
            .append(". ").append(keyCmd)
            .append(": \n\n");

        // Print Command Description
        List<String> exampleDescs = routerUsageInfo.exampleDescs.get(keyCmd);
        if (CollectionUtils.isNotEmpty(exampleDescs)) {
          builder.append("\t\t").append("Cmd Requirement Description:\n");
          for (String value : exampleDescs) {
            String[] valueDescs = StringUtils.split(value, "\\");
            for (String valueDesc : valueDescs) {
              builder.append("\t\t").append(valueDesc).append("\n");
            }
          }
        }

        builder.append("\n");

        // Print Command example
        List<String> valueExamples = example.getValue();
        if (CollectionUtils.isNotEmpty(valueExamples)) {
          builder.append("\t\t").append("Cmd Examples:\n");
          for (String valueExample : valueExamples) {
            builder.append("\t\t").append(valueExample).append("\n");
          }
        }
        builder.append("\n");
        count++;
      }
    }
  }
@Test
  public void testBuildHelpMsg() throws Exception {
    Map<String, RouterCLI.RouterCmdUsageInfos> adminUsage = rmAdminCLI.getAdminUsage();
    assertEquals(3, adminUsage.size());

    RouterCLI.RouterCmdUsageInfos subClusterUsageInfos = adminUsage.get("-subCluster");
    assertNotNull(subClusterUsageInfos);
    Map<String, List<String>> dsExamplesMap = subClusterUsageInfos.getExamples();
    assertNotNull(dsExamplesMap);
    assertEquals(2, dsExamplesMap.size());
    List<String> dsExamples = dsExamplesMap.get("-deregisterSubCluster <-sc|--subClusterId>");
    assertNotNull(dsExamples);
    assertEquals(2, dsExamples.size());
    List<String> getSubClustersExamples = dsExamplesMap.get("-getSubClusters");
    assertNotNull(getSubClustersExamples);
    assertEquals(1, getSubClustersExamples.size());

    RouterCLI.RouterCmdUsageInfos policyUsageInfos = adminUsage.get("-policy");
    assertNotNull(policyUsageInfos);
    Map<String, List<String>> policyExamplesMap = policyUsageInfos.getExamples();
    assertNotNull(policyExamplesMap);
    assertEquals(4, policyExamplesMap.size());
    policyExamplesMap.forEach((cmd, cmdExamples) -> {
      assertEquals(2, cmdExamples.size());
    });

    RouterCLI.RouterCmdUsageInfos applicationUsageInfos = adminUsage.get("-application");
    assertNotNull(applicationUsageInfos);
    Map<String, List<String>> applicationExamplesMap = applicationUsageInfos.getExamples();
    assertNotNull(applicationExamplesMap);
    assertEquals(1, applicationExamplesMap.size());
  }