| | |
| | | import java.util.TreeMap; |
| | | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.util.SetupUtils; |
| | | |
| | | |
| | | |
| | |
| | | // The subcommand requested by the user as part of the command-line arguments. |
| | | private SubCommand subCommand; |
| | | |
| | | private final static String INDENT = " "; |
| | | private final static int MAX_LENGTH = SetupUtils.isWindows() ? 79 : 80; |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | int lineLength = (buffer.length() - currentLength) + |
| | | newBuffer.length(); |
| | | if (lineLength > 80) |
| | | if (lineLength > MAX_LENGTH) |
| | | { |
| | | buffer.append(EOL); |
| | | buffer.append(newBuffer.toString()); |
| | |
| | | // indent the description five characters and try our best to wrap at or |
| | | // before column 79 so it will be friendly to 80-column displays. |
| | | Message description = a.getDescription(); |
| | | if (description.length() <= 75) |
| | | int maxLength = MAX_LENGTH - INDENT.length() - 1; |
| | | if (description.length() <= maxLength) |
| | | { |
| | | buffer.append(" "); |
| | | buffer.append(INDENT); |
| | | buffer.append(description); |
| | | buffer.append(EOL); |
| | | } |
| | | else |
| | | { |
| | | String s = description.toString(); |
| | | while (s.length() > 75) |
| | | while (s.length() > maxLength) |
| | | { |
| | | int spacePos = s.lastIndexOf(' ', 75); |
| | | int spacePos = s.lastIndexOf(' ', maxLength); |
| | | if (spacePos > 0) |
| | | { |
| | | buffer.append(" "); |
| | | buffer.append(INDENT); |
| | | buffer.append(s.substring(0, spacePos).trim()); |
| | | s = s.substring(spacePos+1).trim(); |
| | | buffer.append(EOL); |
| | |
| | | spacePos = s.indexOf(' '); |
| | | if (spacePos > 0) |
| | | { |
| | | buffer.append(" "); |
| | | buffer.append(INDENT); |
| | | buffer.append(s.substring(0, spacePos).trim()); |
| | | s = s.substring(spacePos+1).trim(); |
| | | buffer.append(EOL); |
| | | } |
| | | else |
| | | { |
| | | buffer.append(" "); |
| | | buffer.append(INDENT); |
| | | buffer.append(s); |
| | | s = ""; |
| | | buffer.append(EOL); |
| | |
| | | usageOrVersionDisplayed = true; |
| | | if ((toolDescription != null) && (toolDescription.length() > 0)) |
| | | { |
| | | buffer.append(wrapText(toolDescription, 79)); |
| | | buffer.append(wrapText(toolDescription, MAX_LENGTH - 1)); |
| | | buffer.append(EOL); |
| | | buffer.append(EOL); |
| | | } |
| | |
| | | Message groupDesc = argGroup.getDescription(); |
| | | if (groupDesc != null && !Message.EMPTY.equals(groupDesc)) { |
| | | buffer.append(EOL); |
| | | buffer.append(wrapText(groupDesc.toString(), 79)); |
| | | buffer.append(wrapText(groupDesc.toString(), MAX_LENGTH - 1)); |
| | | buffer.append(EOL); |
| | | buffer.append(EOL); |
| | | } |
| | |
| | | } |
| | | |
| | | buffer.append(EOL); |
| | | indentAndWrap(Message.raw(" "), a.getDescription(), buffer); |
| | | indentAndWrap(Message.raw(INDENT), a.getDescription(), buffer); |
| | | } |
| | | |
| | | |
| | |
| | | private void indentAndWrap(Message indent, Message text, |
| | | MessageBuilder buffer) |
| | | { |
| | | int actualSize = 80 - indent.length(); |
| | | int actualSize = MAX_LENGTH - indent.length(); |
| | | if (text.length() <= actualSize) |
| | | { |
| | | buffer.append(indent); |