use of org.keycloak.quarkus.runtime.configuration.mappers.PropertyMappers in project keycloak by keycloak.
the class Picocli method addMappedOptionsToArgGroups.
private static void addMappedOptionsToArgGroups(CommandSpec cSpec, List<PropertyMapper> propertyMappers) {
for (ConfigCategory category : ConfigCategory.values()) {
List<PropertyMapper> mappersInCategory = propertyMappers.stream().filter(m -> category.equals(m.getCategory())).collect(Collectors.toList());
if (mappersInCategory.isEmpty()) {
// picocli raises an exception when an ArgGroup is empty, so ignore it when no mappings found for a category.
continue;
}
ArgGroupSpec.Builder argGroupBuilder = ArgGroupSpec.builder().heading(category.getHeading() + ":").order(category.getOrder()).validate(false);
for (PropertyMapper mapper : mappersInCategory) {
String name = mapper.getCliFormat();
String description = mapper.getDescription();
if (description == null || cSpec.optionsMap().containsKey(name) || name.endsWith(OPTION_PART_SEPARATOR)) {
// when key is already added or has no description, don't add.
continue;
}
String defaultValue = mapper.getDefaultValue();
Iterable<String> expectedValues = mapper.getExpectedValues();
argGroupBuilder.addArg(OptionSpec.builder(name).defaultValue(defaultValue).description(description).paramLabel(mapper.getParamLabel()).completionCandidates(expectedValues).parameterConsumer(PropertyMapperParameterConsumer.INSTANCE).type(String.class).hidden(mapper.isHidden()).build());
}
cSpec.addArgGroup(argGroupBuilder.build());
}
}
Aggregations