/** * <p>Adds help row headers for option help columns.</p> * * <p>This implementation uses the headers {@code "Option"} and {@code "Description"}. If the options contain * a "required" option, the {@code "Option"} header looks like {@code "Option (* = required)}. Both headers * are "underlined" using {@code "-"}.</p> * * @param options descriptors for the configured options of a parser */ protected void addHeaders( Collection<? extends OptionDescriptor> options ) { if ( hasRequiredOption( options ) ) { addOptionRow( message( "option.header.with.required.indicator" ), message( "description.header" ) ); addOptionRow( message( "option.divider.with.required.indicator" ), message( "description.divider" ) ); } else { addOptionRow( message( "option.header" ), message( "description.header" ) ); addOptionRow( message( "option.divider" ), message( "description.divider" ) ); } }
/** * <p>Adds help row headers for option help columns.</p> * * <p>This implementation uses the headers {@code "Option"} and {@code "Description"}. If the options contain * a "required" option, the {@code "Option"} header looks like {@code "Option (* = required)}. Both headers * are "underlined" using {@code "-"}.</p> * * @param options descriptors for the configured options of a parser */ protected void addHeaders( Collection<? extends OptionDescriptor> options ) { if ( hasRequiredOption( options ) ) { addOptionRow( message( "option.header.with.required.indicator" ), message( "description.header" ) ); addOptionRow( message( "option.divider.with.required.indicator" ), message( "description.divider" ) ); } else { addOptionRow( message( "option.header" ), message( "description.header" ) ); addOptionRow( message( "option.divider" ), message( "description.divider" ) ); } }
return ( descriptor.description() + ' ' + surround( message( "default.value.header" ) + ' ' + defaultValuesDisplay, '(', ')' ) ).trim();
/** * <p>Gives a string representing a description of the option with the given descriptor.</p> * * <p>This implementation:</p> * <ul> * <li>Asks for the descriptor's {@link OptionDescriptor#defaultValues()}</li> * <li>If they're not present, answers the descriptor's {@link OptionDescriptor#description()}.</li> * <li>If they are present, concatenates and returns: * <ul> * <li>the descriptor's {@link OptionDescriptor#description()}</li> * <li>{@code ' '}</li> * <li>{@code "default: "} plus the result of {@link #createDefaultValuesDisplay(java.util.List)}, * surrounded by parentheses</li> * </ul> * </li> * </ul> * * @param descriptor a descriptor for a configured option of a parser * @return display text for the option's description */ protected String createDescriptionDisplay( OptionDescriptor descriptor ) { List<?> defaultValues = descriptor.defaultValues(); if ( defaultValues.isEmpty() ) return descriptor.description(); String defaultValuesDisplay = createDefaultValuesDisplay( defaultValues ); return ( descriptor.description() + ' ' + surround( message( "default.value.header" ) + ' ' + defaultValuesDisplay, '(', ')' ) ).trim(); }
/** * <p>Adds rows of help output for the given options.</p> * * <p>This implementation:</p> * <ul> * <li>Calls {@link #addNonOptionsDescription(java.util.Collection)} with the options as the argument</li> * <li>If there are no options, calls {@link #addOptionRow(String)} with an argument that indicates * that no options are specified.</li> * <li>Otherwise, calls {@link #addHeaders(java.util.Collection)} with the options as the argument, * followed by {@link #addOptions(java.util.Collection)} with the options as the argument.</li> * <li>Calls {@link #fitRowsToWidth()}.</li> * </ul> * * @param options descriptors for the configured options of a parser */ protected void addRows( Collection<? extends OptionDescriptor> options ) { addNonOptionsDescription( options ); if ( options.isEmpty() ) addOptionRow( message( "no.options.specified" ) ); else { addHeaders( options ); addOptions( options ); } fitRowsToWidth(); }
/** * <p>Adds rows of help output for the given options.</p> * * <p>This implementation:</p> * <ul> * <li>Calls {@link #addNonOptionsDescription(java.util.Collection)} with the options as the argument</li> * <li>If there are no options, calls {@link #addOptionRow(String)} with an argument that indicates * that no options are specified.</li> * <li>Otherwise, calls {@link #addHeaders(java.util.Collection)} with the options as the argument, * followed by {@link #addOptions(java.util.Collection)} with the options as the argument.</li> * <li>Calls {@link #fitRowsToWidth()}.</li> * </ul> * * @param options descriptors for the configured options of a parser */ protected void addRows( Collection<? extends OptionDescriptor> options ) { addNonOptionsDescription( options ); if ( options.isEmpty() ) addOptionRow( message( "no.options.specified" ) ); else { addHeaders( options ); addOptions( options ); } fitRowsToWidth(); }
/** * <p>Adds non-option arguments descriptions to the help output.</p> * * <p>This implementation:</p> * <ul> * <li>{@linkplain #findAndRemoveNonOptionsSpec(java.util.Collection) Finds and removes the non-option * arguments descriptor}</li> * <li>{@linkplain #shouldShowNonOptionArgumentDisplay(OptionDescriptor) Decides whether there is * anything to show for non-option arguments}</li> * <li>If there is, {@linkplain #addNonOptionRow(String) adds a header row} and * {@linkplain #addNonOptionRow(String) adds a} * {@linkplain #createNonOptionArgumentsDisplay(OptionDescriptor) non-option arguments description} </li> * </ul> * * @param options descriptors for the configured options of a parser */ protected void addNonOptionsDescription( Collection<? extends OptionDescriptor> options ) { OptionDescriptor nonOptions = findAndRemoveNonOptionsSpec( options ); if ( shouldShowNonOptionArgumentDisplay( nonOptions ) ) { addNonOptionRow( message( "non.option.arguments.header" ) ); addNonOptionRow( createNonOptionArgumentsDisplay( nonOptions ) ); } }
/** * <p>Adds non-option arguments descriptions to the help output.</p> * * <p>This implementation:</p> * <ul> * <li>{@linkplain #findAndRemoveNonOptionsSpec(java.util.Collection) Finds and removes the non-option * arguments descriptor}</li> * <li>{@linkplain #shouldShowNonOptionArgumentDisplay(OptionDescriptor) Decides whether there is * anything to show for non-option arguments}</li> * <li>If there is, {@linkplain #addNonOptionRow(String) adds a header row} and * {@linkplain #addNonOptionRow(String) adds a} * {@linkplain #createNonOptionArgumentsDisplay(OptionDescriptor) non-option arguments description} </li> * </ul> * * @param options descriptors for the configured options of a parser */ protected void addNonOptionsDescription( Collection<? extends OptionDescriptor> options ) { OptionDescriptor nonOptions = findAndRemoveNonOptionsSpec( options ); if ( shouldShowNonOptionArgumentDisplay( nonOptions ) ) { addNonOptionRow( message( "non.option.arguments.header" ) ); addNonOptionRow( createNonOptionArgumentsDisplay( nonOptions ) ); } }