IO io = context.getIo();
UserResource user = new UserResource();
// Prompt for any missing details
PromptReader prompt = promptProvider.get();
// TODO: i18n all of this
// TODO: Add color
if (userId == null) {
userId = prompt.readLine("User ID: ");
}
user.setUserId(userId);
if (name == null) {
name = prompt.readLine("User name: ");
}
user.setName(name);
if (email == null) {
email = prompt.readLine("User email: ");
}
user.setEmail(email);
if (active == null) {
String tmp = prompt.readLine("User active: ");
active = Boolean.parseBoolean(tmp);
}
if (active) {
user.setStatus("active");
}
else {
user.setStatus("disabled");
}
if (userManaged == null) {
String tmp = prompt.readLine("User managed: ");
userManaged = Boolean.parseBoolean(tmp);
}
user.setUserManaged(userManaged);
if (roles == null) {
roles = new ArrayList<String>();
String tmp;
while ((tmp = prompt.readLine("User role: ")) != null && tmp.trim().length() != 0) {
roles.add(tmp);
}
}
user.getRoles().addAll(roles);
if (password == null) {
password = prompt.readPassword("User password: ");
}
user.setPassword(password);
//
// TODO: Verify input if interactive