throw new CommandException(commandErrorSt +
Ansi.ansi().a("too many arguments specified").toString(),
"Too many arguments specified"
);
}
Argument argument = orderedArguments.get(argIndex);
if (!argument.multiValued()) {
argIndex++;
}
if (argument.multiValued()) {
@SuppressWarnings("unchecked")
List<Object> l = (List<Object>) argumentValues.get(argument);
if (l == null) {
l = new ArrayList<Object>();
argumentValues.put(argument, l);
}
l.add(param);
} else {
argumentValues.put(argument, param);
}
}
}
// Check required arguments / options
for (Option option : options.keySet()) {
if (option.required() && optionValues.get(option) == null) {
throw new CommandException(commandErrorSt +
Ansi.ansi().a("option ").bold().a(option.name()).boldOff().a(" is required").toString(),
"Option " + option.name() + " is required"
);
}
}
for (Argument argument : orderedArguments) {
if (argument.required() && argumentValues.get(argument) == null) {
throw new CommandException(commandErrorSt +
Ansi.ansi().a("argument ").bold().a(argument.name()).boldOff().a(" is required").toString(),
"Argument " + argument.name() + " is required"
);
}
}
// Convert and inject values