@Override public String format(final Map<String, ? extends OptionDescriptor> options) { final Set<OptionDescriptor> opts = new LinkedHashSet<OptionDescriptor>( options.values()); lines.addAll(HELP_PREAMBLE); final int helpIndex = lines.size(); StringBuilder sb; for (final OptionDescriptor descriptor : opts) { if (descriptor.representsNonOptions()) continue; final Collection<String> names = descriptor.options(); sb = new StringBuilder().append(" ") .append(optionsToString(names)); if (descriptor.requiresArgument()) sb.append(" uri"); sb.append(": ").append(descriptor.description()); if (names.contains("help")) lines.add(helpIndex, sb.toString()); else lines.add(sb.toString()); } lines.addAll(HELP_POST); return JOINER.join(lines) + LINE_SEPARATOR; }
line.append("REQUIRED: "); line.append(descriptor.description()); List<?> list = descriptor.defaultValues(); if(list!=null&&list.size()>0) {
/** * <p>Appends help for the given non-option arguments descriptor to the given buffer.</p> * * <p>This implementation appends {@code " -- "} if the buffer has text in it and the non-option arguments * descriptor has a {@link OptionDescriptor#description()}; followed by the * {@link OptionDescriptor#description()}.</p> * * @param buffer string buffer * @param nonOptions non-option arguments descriptor */ protected void maybeAppendNonOptionsDescription( StringBuilder buffer, OptionDescriptor nonOptions ) { buffer.append( buffer.length() > 0 && !Strings.isNullOrEmpty( nonOptions.description() ) ? " -- " : "" ) .append( nonOptions.description() ); }
/** * <p>Appends help for the given non-option arguments descriptor to the given buffer.</p> * * <p>This implementation appends {@code " -- "} if the buffer has text in it and the non-option arguments * descriptor has a {@link OptionDescriptor#description()}; followed by the * {@link OptionDescriptor#description()}.</p> * * @param buffer string buffer * @param nonOptions non-option arguments descriptor */ protected void maybeAppendNonOptionsDescription( StringBuilder buffer, OptionDescriptor nonOptions ) { buffer.append( buffer.length() > 0 && !Strings.isNullOrEmpty( nonOptions.description() ) ? " -- " : "" ) .append( nonOptions.description() ); }
OptionHelpAdapter(OptionDescriptor descriptor) { this.options = new LinkedHashSet<>(); for (String option : descriptor.options()) { String prefix = (option.length() != 1) ? "--" : "-"; this.options.add(prefix + option); } if (this.options.contains("--cp")) { this.options.remove("--cp"); this.options.add("-cp"); } this.description = descriptor.description(); }
private String createDescriptionDisplay( OptionDescriptor descriptor ) { List<?> defaultValues = descriptor.defaultValues(); if ( defaultValues.isEmpty() ) return descriptor.description(); String defaultValuesDisplay = createDefaultValuesDisplay( defaultValues ); return descriptor.description() + ' ' + surround( "default: " + defaultValuesDisplay, '(', ')' ); }
private String createDescriptionDisplay( OptionDescriptor descriptor ) { List<?> defaultValues = descriptor.defaultValues(); if ( defaultValues.isEmpty() ) return descriptor.description(); String defaultValuesDisplay = createDefaultValuesDisplay( defaultValues ); return descriptor.description() + ' ' + surround( "default: " + defaultValuesDisplay, '(', ')' ); }
private String createDescriptionDisplay( OptionDescriptor descriptor ) { List<?> defaultValues = descriptor.defaultValues(); if ( defaultValues.isEmpty() ) return descriptor.description(); String defaultValuesDisplay = createDefaultValuesDisplay( defaultValues ); return descriptor.description() + ' ' + surround( "default: " + defaultValuesDisplay, '(', ')' ); }
/** * <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(); }
for (String l : rewrap(d.description())) { if (first) { first = false;
List<?> defaultValues = descriptor.defaultValues(); if ( defaultValues.isEmpty() ) return descriptor.description(); .collect( toList() ); String defaultValuesDisplay = createDefaultValuesDisplay( stringifiedDefaults ); return ( descriptor.description() + ' ' + surround( message( "default.value.header" ) + ' ' + defaultValuesDisplay, '(', ')' )
for (String l : rewrap(d.description())) { if (first) { first = false;
sb.append(od.description());
/** * <p>Decides whether or not to show a non-option arguments help.</p> * * <p>This implementation responds with {@code true} if the non-option descriptor has a non-{@code null}, * non-empty value for any of {@link OptionDescriptor#description()}, * {@link OptionDescriptor#argumentTypeIndicator()}, or {@link OptionDescriptor#argumentDescription()}.</p> * * @param nonOptionDescriptor non-option argument descriptor * @return {@code true} if non-options argument help should be shown */ protected boolean shouldShowNonOptionArgumentDisplay( OptionDescriptor nonOptionDescriptor ) { return !Strings.isNullOrEmpty( nonOptionDescriptor.description() ) || !Strings.isNullOrEmpty( nonOptionDescriptor.argumentTypeIndicator() ) || !Strings.isNullOrEmpty( nonOptionDescriptor.argumentDescription() ); }
/** * <p>Decides whether or not to show a non-option arguments help.</p> * * <p>This implementation responds with {@code true} if the non-option descriptor has a non-{@code null}, * non-empty value for any of {@link OptionDescriptor#description()}, * {@link OptionDescriptor#argumentTypeIndicator()}, or {@link OptionDescriptor#argumentDescription()}.</p> * * @param nonOptionDescriptor non-option argument descriptor * @return {@code true} if non-options argument help should be shown */ protected boolean shouldShowNonOptionArgumentDisplay( OptionDescriptor nonOptionDescriptor ) { return !Strings.isNullOrEmpty( nonOptionDescriptor.description() ) || !Strings.isNullOrEmpty( nonOptionDescriptor.argumentTypeIndicator() ) || !Strings.isNullOrEmpty( nonOptionDescriptor.argumentDescription() ); }