import org.asamk.signal.manager.Manager;
import org.whispersystems.signalservice.api.util.InvalidNumberException;
+import java.io.IOException;
+
public class UpdateContactCommand implements LocalCommand {
@Override
subparser.addArgument("-n", "--name")
.required(true)
.help("New contact name");
+ subparser.addArgument("-e", "--expiration")
+ .required(false)
+ .type(int.class)
+ .help("Set expiration time of messages (seconds)");
subparser.help("Update the details of a given contact");
}
try {
m.setContactName(number, name);
+
+ Integer expiration = ns.getInt("expiration");
+ if (expiration != null) {
+ m.setExpirationTimer(number, expiration);
+ }
} catch (InvalidNumberException e) {
- System.out.println("Invalid contact number: " + e.getMessage());
+ System.err.println("Invalid contact number: " + e.getMessage());
+ return 1;
+ } catch (IOException e) {
+ System.err.println("Update contact error: " + e.getMessage());
+ return 3;
}
return 0;