mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Create an AvatarStore
This commit is contained in:
parent
6bd857ad8b
commit
a643609ed2
9 changed files with 239 additions and 159 deletions
|
@ -6,6 +6,7 @@ import net.sourceforge.argparse4j.inf.Namespace;
|
|||
import net.sourceforge.argparse4j.inf.Subparser;
|
||||
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -14,7 +15,7 @@ public class UpdateProfileCommand implements LocalCommand {
|
|||
|
||||
@Override
|
||||
public void attachToSubparser(final Subparser subparser) {
|
||||
final MutuallyExclusiveGroup avatarOptions = subparser.addMutuallyExclusiveGroup().required(true);
|
||||
final MutuallyExclusiveGroup avatarOptions = subparser.addMutuallyExclusiveGroup();
|
||||
avatarOptions.addArgument("--avatar").help("Path to new profile avatar");
|
||||
avatarOptions.addArgument("--remove-avatar").action(Arguments.storeTrue());
|
||||
|
||||
|
@ -30,7 +31,9 @@ public class UpdateProfileCommand implements LocalCommand {
|
|||
boolean removeAvatar = ns.getBoolean("remove_avatar");
|
||||
|
||||
try {
|
||||
File avatarFile = removeAvatar ? null : new File(avatarPath);
|
||||
Optional<File> avatarFile = removeAvatar
|
||||
? Optional.absent()
|
||||
: avatarPath == null ? null : Optional.of(new File(avatarPath));
|
||||
m.setProfile(name, avatarFile);
|
||||
} catch (IOException e) {
|
||||
System.err.println("UpdateAccount error: " + e.getMessage());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue