HAAdmin extends Configured implements Tool { private int help(String[] argv) { if (argv.length == 1) { printUsage(out); return 0; } else if (argv.length != 2) { printUsage(errOut, "-help"); return -1; } String cmd = argv[1]; if (!cmd.startsWith("-")) { cmd = "-" + cmd; } UsageInfo usageInfo = USAGE.get(cmd); if (usageInfo == null) { errOut.println(cmd + ": Unknown command"); printUsage(errOut); return -1; } if (usageInfo.args == null) { out.println(cmd + ": " + usageInfo.help); } else { out.println(cmd + " [" + usageInfo.args + "]: " + usageInfo.help); } return 0; } protected  HAAdmin(); protected  HAAdmin(Configuration conf); @Override void setConf(Configuration conf); @Override int run(String[] argv);  }
@Test public void testHelp() throws Exception { assertEquals(0, runTool("-help")); assertEquals(0, runTool("-help", "transitionToActive")); assertOutputContains("Transitions the service into Active"); }