Search in sources :

Example 1 with CommandMetadata

use of io.airlift.airline.model.CommandMetadata in project atlasdb by palantir.

the class AtlasDbCliCommand method getOptionTypesForCommandMetadata.

@VisibleForTesting
static Map<String, OptionType> getOptionTypesForCommandMetadata(CommandMetadata subCommand) {
    Map<String, OptionType> optionTypes = new HashMap<>();
    List<OptionMetadata> commandOptions = ImmutableList.<OptionMetadata>builder().addAll(subCommand.getCommandOptions()).addAll(subCommand.getGroupOptions()).addAll(subCommand.getGlobalOptions()).build();
    for (OptionMetadata option : commandOptions) {
        if (option.isHidden()) {
            continue;
        }
        List<String> sortedOptions = option.getOptions().stream().sorted((first, second) -> Integer.compareUnsigned(first.length(), second.length())).collect(Collectors.toList());
        String longOption = Iterables.getLast(sortedOptions);
        optionTypes.put(longOption, option.getOptionType());
    }
    return ImmutableMap.copyOf(optionTypes);
}
Also used : AtlasCli(com.palantir.atlasdb.cli.AtlasCli) Iterables(com.google.common.collect.Iterables) Bootstrap(io.dropwizard.setup.Bootstrap) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) Callable(java.util.concurrent.Callable) AtlasDbConfigurationProvider(com.palantir.atlasdb.dropwizard.AtlasDbConfigurationProvider) OptionMetadata(io.airlift.airline.model.OptionMetadata) Configuration(io.dropwizard.Configuration) ImmutableList(com.google.common.collect.ImmutableList) Map(java.util.Map) Namespace(net.sourceforge.argparse4j.inf.Namespace) Argument(net.sourceforge.argparse4j.inf.Argument) Logger(org.slf4j.Logger) ImmutableMap(com.google.common.collect.ImmutableMap) Subparser(net.sourceforge.argparse4j.inf.Subparser) Cli(io.airlift.airline.Cli) Collectors(java.util.stream.Collectors) Maps(com.google.common.collect.Maps) CommandGroupMetadata(io.airlift.airline.model.CommandGroupMetadata) List(java.util.List) Arguments(net.sourceforge.argparse4j.impl.Arguments) OptionType(io.airlift.airline.OptionType) VisibleForTesting(com.google.common.annotations.VisibleForTesting) CommandMetadata(io.airlift.airline.model.CommandMetadata) AtlasDbConfig(com.palantir.atlasdb.config.AtlasDbConfig) OptionMetadata(io.airlift.airline.model.OptionMetadata) HashMap(java.util.HashMap) OptionType(io.airlift.airline.OptionType) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Iterables (com.google.common.collect.Iterables)1 Maps (com.google.common.collect.Maps)1 AtlasCli (com.palantir.atlasdb.cli.AtlasCli)1 AtlasDbConfig (com.palantir.atlasdb.config.AtlasDbConfig)1 AtlasDbConfigurationProvider (com.palantir.atlasdb.dropwizard.AtlasDbConfigurationProvider)1 Cli (io.airlift.airline.Cli)1 OptionType (io.airlift.airline.OptionType)1 CommandGroupMetadata (io.airlift.airline.model.CommandGroupMetadata)1 CommandMetadata (io.airlift.airline.model.CommandMetadata)1 OptionMetadata (io.airlift.airline.model.OptionMetadata)1 Configuration (io.dropwizard.Configuration)1 Bootstrap (io.dropwizard.setup.Bootstrap)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Callable (java.util.concurrent.Callable)1 Collectors (java.util.stream.Collectors)1