| | |
| | | |
| | | import static com.forgerock.opendj.util.StaticUtils.*; |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.*; |
| | | import static com.forgerock.opendj.cli.Utils.MAX_LINE_WIDTH; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | |
| | | private boolean versionPresent; |
| | | |
| | | private static final String INDENT = " "; |
| | | private final static int MAX_LENGTH = 80; |
| | | |
| | | /** |
| | | * Creates a new instance of this subcommand argument parser with no arguments. |
| | |
| | | } |
| | | |
| | | int lineLength = (buffer.length() - currentLength) + newBuffer.length(); |
| | | if (lineLength > MAX_LENGTH) { |
| | | if (lineLength > MAX_LINE_WIDTH) { |
| | | buffer.append(EOL); |
| | | } |
| | | buffer.append(newBuffer.toString()); |
| | |
| | | * FIXME Try to merge with #indentAndWrap(LocalizableMessage, LocalizableMessage, LocalizableMessageBuilder). |
| | | */ |
| | | private void indentAndWrap2(String indent, LocalizableMessage text, LocalizableMessageBuilder buffer) { |
| | | int actualSize = MAX_LENGTH - indent.length() - 1; |
| | | int actualSize = MAX_LINE_WIDTH - indent.length() - 1; |
| | | indentAndWrap(indent, actualSize, text, buffer); |
| | | } |
| | | |
| | |
| | | private void getFullUsage(Collection<SubCommand> c, boolean showGlobalOptions, LocalizableMessageBuilder buffer) { |
| | | usageOrVersionDisplayed = true; |
| | | if (toolDescription != null && toolDescription.length() > 0) { |
| | | buffer.append(wrapText(toolDescription, MAX_LENGTH - 1)); |
| | | buffer.append(EOL); |
| | | buffer.append(EOL); |
| | | buffer.append(wrapText(toolDescription, MAX_LINE_WIDTH - 1)); |
| | | buffer.append(EOL).append(EOL); |
| | | } |
| | | |
| | | String scriptName = System.getProperty(PROPERTY_SCRIPT_NAME); |
| | |
| | | } else { |
| | | buffer.append(INFO_SUBCMDPARSER_GLOBAL_HEADING.get()); |
| | | } |
| | | buffer.append(EOL); |
| | | buffer.append(EOL); |
| | | buffer.append(EOL).append(EOL); |
| | | |
| | | boolean printGroupHeaders = printUsageGroupHeaders(); |
| | | |
| | |
| | | LocalizableMessage groupDesc = argGroup.getDescription(); |
| | | if (groupDesc != null && !LocalizableMessage.EMPTY.equals(groupDesc)) { |
| | | buffer.append(EOL); |
| | | buffer.append(wrapText(groupDesc.toString(), MAX_LENGTH - 1)); |
| | | buffer.append(EOL); |
| | | buffer.append(EOL); |
| | | buffer.append(wrapText(groupDesc.toString(), MAX_LINE_WIDTH - 1)); |
| | | buffer.append(EOL).append(EOL); |
| | | } |
| | | } |
| | | |
| | |
| | | * try our best to wrap at or before column 79 so it will be friendly to 80-column displays. |
| | | */ |
| | | private void indentAndWrap(String indent, LocalizableMessage text, LocalizableMessageBuilder buffer) { |
| | | int actualSize = MAX_LENGTH - indent.length(); |
| | | int actualSize = MAX_LINE_WIDTH - indent.length(); |
| | | indentAndWrap(indent, actualSize, text, buffer); |
| | | } |
| | | |
| | |
| | | spacePos = s.indexOf(' '); |
| | | } |
| | | if (spacePos == -1) { |
| | | buffer.append(indent); |
| | | buffer.append(s); |
| | | buffer.append(EOL); |
| | | buffer.append(indent).append(s).append(EOL); |
| | | return; |
| | | } |
| | | buffer.append(indent); |
| | |
| | | } |
| | | |
| | | if (s.length() > 0) { |
| | | buffer.append(indent); |
| | | buffer.append(s); |
| | | buffer.append(EOL); |
| | | buffer.append(indent).append(s).append(EOL); |
| | | } |
| | | } |
| | | } |