- if (removeAvatar) {
- try {
- m.removeProfileAvatar();
- } catch (IOException e) {
- System.err.println("UpdateAccount error: " + e.getMessage());
- return 3;
- }
+ @Override
+ public void handleCommand(
+ final Namespace ns, final Manager m, final OutputWriter outputWriter
+ ) throws CommandException {
+ var givenName = ns.getString("given-name");
+ var familyName = ns.getString("family-name");
+ var about = ns.getString("about");
+ var aboutEmoji = ns.getString("about-emoji");
+ var avatarPath = ns.getString("avatar");
+ boolean removeAvatar = Boolean.TRUE.equals(ns.getBoolean("remove-avatar"));
+
+ Optional<File> avatarFile = removeAvatar
+ ? Optional.absent()
+ : avatarPath == null ? null : Optional.of(new File(avatarPath));
+
+ try {
+ m.setProfile(givenName, familyName, about, aboutEmoji, avatarFile);
+ } catch (IOException e) {
+ throw new IOErrorException("Update profile error: " + e.getMessage(), e);