.a(entry.getKey().name())
.a(Ansi.Attribute.INTENSITY_BOLD_OFF)
.a(" with value '")
.a(entry.getValue())
.a("' to type ")
.a(new GenericType(field.getGenericType()).toString())
.fg(Ansi.Color.DEFAULT)
.toString(),
"Unable to convert option " + entry.getKey().name() + " with value '"
+ entry.getValue() + "' to type " + new GenericType(field.getGenericType()).toString(),
e
);
} else {
throw new CommandException("Unable to convert option " + entry.getKey().name() + " with value '"
+ entry.getValue() + "' to type " + new GenericType(field.getGenericType()).toString(),
e);
}
}
field.setAccessible(true);
field.set(action, value);
}
for (Map.Entry<Argument, Object> entry : argumentValues.entrySet()) {
Field field = arguments.get(entry.getKey());
Object value;
try {
value = convert(action, session, entry.getValue(), field.getGenericType());
} catch (Exception e) {
Command command = action.getClass().getAnnotation(Command.class);
if (command != null) {
throw new CommandException(
Ansi.ansi()
.fg(Ansi.Color.RED)
.a("Error executing command ")
.a(command.scope())
.a(":")
.a(Ansi.Attribute.INTENSITY_BOLD)
.a(command.name())
.a(Ansi.Attribute.INTENSITY_BOLD_OFF)
.a(": unable to convert argument ")
.a(Ansi.Attribute.INTENSITY_BOLD)
.a(entry.getKey().name())
.a(Ansi.Attribute.INTENSITY_BOLD_OFF)
.a(" with value '")
.a(entry.getValue())
.a("' to type ")
.a(new GenericType(field.getGenericType()).toString())
.fg(Ansi.Color.DEFAULT)
.toString(),
"Unable to convert argument " + entry.getKey().name() + " with value '"
+ entry.getValue() + "' to type " + new GenericType(field.getGenericType()).toString(),
e
);
} else {
throw new CommandException("Unable to convert argument " + entry.getKey().name() + " with value '"
+ entry.getValue() + "' to type " + new GenericType(field.getGenericType()).toString(),
e);
}
}
field.setAccessible(true);
field.set(action, value);