Object[] parameters = new Object[command.getOptions().size()];
for (OptionMetadata option : command.getOptions())
{
PromptType promptType = option.getPromptType();
String defaultValue = option.getDefaultValue();
Class<?> optionType = option.getBoxedType();
String optionDescriptor = option.getOptionDescriptor() + ": ";
Object value;
if (option.isPipeOut())
{
value = pipeOut;
}
else if (option.isPipeIn())
{
value = pipeIn;
if (pipeIn != null)
{
if (InputStream.class.isAssignableFrom(option.getBoxedType()))
{
value = new InputStream()
{
int cursor = 0;
int len = pipeIn.length();
@Override
public int read() throws IOException
{
return cursor != len ? pipeIn.charAt(cursor++) : -1;
}
};
}
}
}
else
{
value = valueMap.get(option);
}
if (!option.isPipeOut() && !option.isPipeIn())
{
// TODO Is this really where we want to do PromptType conversion?
value = doPromptTypeConversions(value, promptType);
if ((value != null) && option.getBoxedType().isEnum() && !Enums.hasValue(option.getType(), value))
{
ShellMessages.info(shell, "Could not parse [" + value + "]... please try again...");
if (!option.hasCustomCompleter())
{
value = shell.promptEnum(optionDescriptor, (Class<Enum>) option.getType());
}
else
{
value = shell.promptCompleter(optionDescriptor, option.getCompleterType());
}
}
else if (((value != null) && (promptType != null)) && !promptType.matches(value.toString()))
{
// make sure the current option value is OK
ShellMessages.info(shell, "Could not parse [" + value + "]... please try again...");
if (promptType.equals(PromptType.JAVA_PACKAGE))
{
String defaultPackage = value == null ? "" : Packages.toValidPackageName((String) value);
value = shell.promptCommon(optionDescriptor, promptType, defaultPackage);
}
else