@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; }
if (d.acceptsArguments()) { o.append(" "); if (d.requiresArgument()) { o.append("<"); } else { if (d.requiresArgument()) { o.append(">"); } else {
if (d.acceptsArguments()) { o.append(" "); if (d.requiresArgument()) { o.append("<"); } else { if (d.requiresArgument()) { o.append(">"); } else {
sb.append(" --"); sb.append(od.options().iterator().next()); if (!od.requiresArgument()) { sb.append(" <?>");
private void addHelpLineFor( OptionDescriptor descriptor ) { if ( descriptor.acceptsArguments() ) { if ( descriptor.requiresArgument() ) addHelpLineWithArgument( descriptor, '<', '>' ); else addHelpLineWithArgument( descriptor, '[', ']' ); } else { addHelpLineFor( descriptor, "" ); } }
private void addHelpLineFor( OptionDescriptor descriptor ) { if ( descriptor.acceptsArguments() ) { if ( descriptor.requiresArgument() ) addHelpLineWithArgument( descriptor, '<', '>' ); else addHelpLineWithArgument( descriptor, '[', ']' ); } else { addHelpLineFor( descriptor, "" ); } }
private void addHelpLineFor( OptionDescriptor descriptor ) { if ( descriptor.acceptsArguments() ) { if ( descriptor.requiresArgument() ) addHelpLineWithArgument( descriptor, '<', '>' ); else addHelpLineWithArgument( descriptor, '[', ']' ); } else { addHelpLineFor( descriptor, "" ); } }
/** * <p>Appends additional info about the given option to the given buffer.</p> * * <p>This implementation:</p> * <ul> * <li>calls {@link #extractTypeIndicator(OptionDescriptor)} for the descriptor</li> * <li>calls {@link joptsimple.OptionDescriptor#argumentDescription()} for the descriptor</li> * <li>if either of the above is present, calls * {@link #appendOptionHelp(StringBuilder, String, String, boolean)}</li> * </ul> * * @param buffer string buffer * @param descriptor a descriptor for a configured option of a parser */ protected void maybeAppendOptionInfo( StringBuilder buffer, OptionDescriptor descriptor ) { String indicator = extractTypeIndicator( descriptor ); String description = descriptor.argumentDescription(); if ( descriptor.acceptsArguments() || !isNullOrEmpty( description ) || descriptor.representsNonOptions() ) { appendOptionHelp( buffer, indicator, description, descriptor.requiresArgument() ); } }
/** * <p>Appends additional info about the given option to the given buffer.</p> * * <p>This implementation:</p> * <ul> * <li>calls {@link #extractTypeIndicator(OptionDescriptor)} for the descriptor</li> * <li>calls {@link joptsimple.OptionDescriptor#argumentDescription()} for the descriptor</li> * <li>if either of the above is present, calls * {@link #appendOptionHelp(StringBuilder, String, String, boolean)}</li> * </ul> * * @param buffer string buffer * @param descriptor a descriptor for a configured option of a parser */ protected void maybeAppendOptionInfo( StringBuilder buffer, OptionDescriptor descriptor ) { String indicator = extractTypeIndicator( descriptor ); String description = descriptor.argumentDescription(); if ( descriptor.acceptsArguments() || !isNullOrEmpty( description ) || descriptor.representsNonOptions() ) { appendOptionHelp( buffer, indicator, description, descriptor.requiresArgument() ); } }