@Override public TypedOption<T> setLongName(String longName) { super.setLongName(longName); return this; }
@Override public TypedOption<T> setMultiValued(boolean acceptMultipleValues) { super.setMultiValued(acceptMultipleValues); return this; }
@Override public TypedOption<T> setArgName(String argName) { super.setArgName(argName); return this; }
public static CLI define() { return new DefaultCLI().setName("bye").addOption(new TypedOption<String>() .setType(String.class) .setRequired(true) .setShortName("n") .setSingleValued(true)) .setSummary("A command saying goodbye."); }
private void checkRequiredValues() throws MissingValueException { if (current != null) { if (current.acceptValue() && !commandLine.isOptionAssigned(current) && !current.isFlag()) { throw new MissingValueException(current); } } }
private boolean hasOptionWithLongName(String name) { for (Option option : cli.getOptions()) { if (name.equalsIgnoreCase(option.getLongName())) { return true; } } return false; }
@Override public TypedOption<T> setDescription(String description) { super.setDescription(description); return this; }
@Override public TypedOption<T> setShortName(String shortName) { super.setShortName(shortName); return this; }
@Override public TypedArgument<T> setIndex(int index) { super.setIndex(index); return this; }
/** * @return the {@link CLI}. */ public CLI cli() { return commandLine.cli(); }
@Override public TypedArgument<T> setDescription(String description) { super.setDescription(description); return this; }
@Override public CLI usage(StringBuilder builder) { new UsageMessageFormatter().usage(builder, this); return this; }
@Override public TypedOption<T> setSingleValued(boolean acceptSingleValue) { super.setSingleValued(acceptSingleValue); return this; }
/** * Creates a new instance of {@link TypedArgument} by copying the state of another {@link TypedArgument}. * * @param arg the copied argument */ public TypedArgument(TypedArgument<T> arg) { super(arg); this.type = arg.getType(); this.converter = arg.getConverter(); }
/** * Creates a new instance of {@link MissingValueException} when an option requiring a value does not receive a value. * * @param option the option */ public MissingValueException(Option option) { super("The option '" + option.getName() + "' requires a value"); this.argument = null; this.option = option; }
/** * Builds the specified text to the specified buffer. * * @param buffer The buffer to write the help to * @param text The text to be written to the buffer */ public void buildWrapped(StringBuilder buffer, String text) { buildWrapped(buffer, 0, text); }
/** * Creates a new instance of {@link Argument} from the given JSON object. * * @param json the json object * @see #toJson() */ public Argument(JsonObject json) { this(); ArgumentConverter.fromJson(json, this); }
@Override public TypedOption<T> setChoices(Set<String> choices) { super.setChoices(choices); return this; }
/** * Creates a new instance of {@link Option} from the given {@link JsonObject} * * @param json the json object representing the option * @see #toJson() */ public Option(JsonObject json) { this(); OptionConverter.fromJson(json, this); }
@Override public CLI usage(StringBuilder builder, String prefix) { new UsageMessageFormatter().usage(builder, prefix, this); return this; } }