Search in sources :

Example 1 with Build

use of org.keycloak.quarkus.runtime.cli.command.Build 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());
    }
}
Also used : PersistedConfigSource(org.keycloak.quarkus.runtime.configuration.PersistedConfigSource) ConfigArgsConfigSource.parseConfigArgs(org.keycloak.quarkus.runtime.configuration.ConfigArgsConfigSource.parseConfigArgs) UnaryOperator(java.util.function.UnaryOperator) Configuration.getRuntimeProperty(org.keycloak.quarkus.runtime.configuration.Configuration.getRuntimeProperty) ArrayList(java.util.ArrayList) Environment.isDevMode(org.keycloak.quarkus.runtime.Environment.isDevMode) ConfigArgsConfigSource(org.keycloak.quarkus.runtime.configuration.ConfigArgsConfigSource) AUTO_BUILD_OPTION_SHORT(org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand.AUTO_BUILD_OPTION_SHORT) PropertyMappers(org.keycloak.quarkus.runtime.configuration.mappers.PropertyMappers) Build(org.keycloak.quarkus.runtime.cli.command.Build) Map(java.util.Map) BiConsumer(java.util.function.BiConsumer) StringUtil.isNotBlank(org.keycloak.utils.StringUtil.isNotBlank) OptionSpec(picocli.CommandLine.Model.OptionSpec) CommandLine(picocli.CommandLine) PrintWriter(java.io.PrintWriter) Environment(org.keycloak.quarkus.runtime.Environment) PropertyMappers.formatValue(org.keycloak.quarkus.runtime.configuration.mappers.PropertyMappers.formatValue) Configuration.getConfig(org.keycloak.quarkus.runtime.configuration.Configuration.getConfig) OPTION_PART_SEPARATOR(org.keycloak.quarkus.runtime.configuration.Configuration.OPTION_PART_SEPARATOR) Iterator(java.util.Iterator) Main(org.keycloak.quarkus.runtime.cli.command.Main) Predicate(java.util.function.Predicate) Set(java.util.Set) ConfigArgsConfigSource.hasOptionValue(org.keycloak.quarkus.runtime.configuration.ConfigArgsConfigSource.hasOptionValue) ArgGroupSpec(picocli.CommandLine.Model.ArgGroupSpec) Collectors(java.util.stream.Collectors) ConfigValue(io.smallrye.config.ConfigValue) PropertyMappers.isBuildTimeProperty(org.keycloak.quarkus.runtime.configuration.mappers.PropertyMappers.isBuildTimeProperty) File(java.io.File) List(java.util.List) Start(org.keycloak.quarkus.runtime.cli.command.Start) Configuration.getBuildTimeProperty(org.keycloak.quarkus.runtime.configuration.Configuration.getBuildTimeProperty) Optional(java.util.Optional) ConfigCategory(org.keycloak.quarkus.runtime.configuration.mappers.ConfigCategory) PropertyMapper(org.keycloak.quarkus.runtime.configuration.mappers.PropertyMapper) SECTION_KEY_COMMAND_LIST(picocli.CommandLine.Model.UsageMessageSpec.SECTION_KEY_COMMAND_LIST) CommandSpec(picocli.CommandLine.Model.CommandSpec) Quarkus(io.quarkus.runtime.Quarkus) StartDev(org.keycloak.quarkus.runtime.cli.command.StartDev) AUTO_BUILD_OPTION_LONG(org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand.AUTO_BUILD_OPTION_LONG) ConfigCategory(org.keycloak.quarkus.runtime.configuration.mappers.ConfigCategory) ArgGroupSpec(picocli.CommandLine.Model.ArgGroupSpec) PropertyMapper(org.keycloak.quarkus.runtime.configuration.mappers.PropertyMapper)

Aggregations

Quarkus (io.quarkus.runtime.Quarkus)1 ConfigValue (io.smallrye.config.ConfigValue)1 File (java.io.File)1 PrintWriter (java.io.PrintWriter)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 BiConsumer (java.util.function.BiConsumer)1 Predicate (java.util.function.Predicate)1 UnaryOperator (java.util.function.UnaryOperator)1 Collectors (java.util.stream.Collectors)1 Environment (org.keycloak.quarkus.runtime.Environment)1 Environment.isDevMode (org.keycloak.quarkus.runtime.Environment.isDevMode)1 AUTO_BUILD_OPTION_LONG (org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand.AUTO_BUILD_OPTION_LONG)1 AUTO_BUILD_OPTION_SHORT (org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand.AUTO_BUILD_OPTION_SHORT)1 Build (org.keycloak.quarkus.runtime.cli.command.Build)1 Main (org.keycloak.quarkus.runtime.cli.command.Main)1