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);
}
Aggregations