public void printUsage() { Options options = getOptions(); HelpFormatter helpFormatter = new HelpFormatter(); String header = "\n" + getDescription() + "\n\n"; String syntax; if (options.getOptions().isEmpty()) { syntax = "rhqctl " + getName(); } else { syntax = "rhqctl " + getName() + " [options]"; } helpFormatter.setNewLine("\n"); helpFormatter.printHelp(syntax, header, options, null); // we can't pass this as the last argument to printHelp above // because it throws an exception if the string is too long. String readmeContent = getReadmeContent(); if (readmeContent != null) { System.out.println(readmeContent); } }