Map<String, InputComponent<?, Object>> inputs)
{
ParserBuilder builder = new ParserBuilder();
UICommandMetadata metadata = command.getMetadata();
CommandInt parameter = new CommandInt(ShellUtil.shellifyName(metadata.getName()), metadata.getDescription());
for (InputComponent<?, Object> input : inputs.values())
{
Object defaultValue = InputComponents.getValueFor(input);
boolean isMultiple = input instanceof ManyValued;
boolean hasValue = (InputComponents.getInputType(input) != InputType.CHECKBOX && !Boolean.class
.isAssignableFrom(input.getValueType()));
try
{
OptionBuilder optionBuilder = new OptionBuilder();
optionBuilder.name(input.getName())
.addDefaultValue(defaultValue == null ? null : defaultValue.toString())
.description(input.getLabel())
.hasMultipleValues(isMultiple)
.hasValue(hasValue)
.required(input.isRequired());
if (input.getShortName() != InputComponents.DEFAULT_SHORT_NAME)
{
optionBuilder.shortName(input.getShortName());
}
OptionInt option = optionBuilder.create();
if (input.getName().equals("arguments"))
{
parameter.setArgument(option);
}
else
{
parameter.addOption(option);
}
}
catch (OptionParserException e)
{
logger.log(Level.SEVERE, "Error while parsing command option", e);