use of com.lexicalscope.jewel.cli.specification.UnparsedOptionSpecification in project jewelcli by lexicalscope.
the class ArgumentPresenterImpl method presentArguments.
@Option
public O presentArguments(final OptionCollection validatedArguments) throws ArgumentValidationException {
final Map<String, Object> argumentMap = new LinkedHashMap<String, Object>();
final ValidationErrorBuilder validationErrorBuilder = new ValidationErrorBuilderImpl();
for (final ParsedOptionSpecification optionSpecification : specification) {
final ConvertTypeOfObject<?> convertTypeOfObject = converterTo(validationErrorBuilder, optionSpecification, optionSpecification.getMethod());
putDefaultInMap(argumentMap, optionSpecification, convertTypeOfObject);
final Argument argument = validatedArguments.getArgument(optionSpecification);
if (argument != null) {
putValuesInMap(argumentMap, optionSpecification, convertTypeOfObject, argument.getValues());
}
}
if (specification.hasUnparsedSpecification()) {
final UnparsedOptionSpecification unparsedSpecification = specification.getUnparsedSpecification();
final ConvertTypeOfObject<?> convertTypeOfObject = converterTo(validationErrorBuilder, unparsedSpecification, unparsedSpecification.getMethod());
putDefaultInMap(argumentMap, unparsedSpecification, convertTypeOfObject);
if (!validatedArguments.getUnparsed().isEmpty()) {
putValuesInMap(argumentMap, unparsedSpecification, convertTypeOfObject, validatedArguments.getUnparsed());
}
}
validationErrorBuilder.validate();
return argumentPresentingStrategy.presentArguments(argumentMap);
}
Aggregations