* if the command line arguments were invalid.
* @see Option
* @see Argument
*/
protected void parseCommandLine(Object options) throws UnloggedFailure {
final CmdLineParser clp = newCmdLineParser(options);
try {
clp.parseArgument(argv);
} catch (IllegalArgumentException err) {
if (!clp.wasHelpRequestedByOption()) {
throw new UnloggedFailure(1, "fatal: " + err.getMessage());
}
} catch (CmdLineException err) {
if (!clp.wasHelpRequestedByOption()) {
throw new UnloggedFailure(1, "fatal: " + err.getMessage());
}
}
if (clp.wasHelpRequestedByOption()) {
CommandMetaData meta = getClass().getAnnotation(CommandMetaData.class);
String title = meta.name().toUpperCase() + ": " + meta.description();
String b = com.gitblit.utils.StringUtils.leftPad("", title.length() + 2, '═');
StringWriter msg = new StringWriter();
msg.write('\n');
msg.write(b);
msg.write('\n');
msg.write(' ');
msg.write(title);
msg.write('\n');
msg.write(b);
msg.write("\n\n");
msg.write("USAGE\n");
msg.write("─────\n");
msg.write(' ');
msg.write(commandName);
msg.write('\n');
msg.write(" ");
clp.printSingleLineUsage(msg, null);
msg.write("\n\n");
String txt = getUsageText();
if (!StringUtils.isEmpty(txt)) {
msg.write(txt);
msg.write("\n\n");
}
msg.write("ARGUMENTS & OPTIONS\n");
msg.write("───────────────────\n");
clp.printUsage(msg, null);
msg.write('\n');
String examples = usage().trim();
if (!StringUtils.isEmpty(examples)) {
msg.write('\n');
msg.write("EXAMPLES\n");