mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Add listContacts subcommand (#248)
This commit is contained in:
parent
b402b65066
commit
e508fc50e9
3 changed files with 32 additions and 0 deletions
|
@ -11,6 +11,7 @@ public class Commands {
|
||||||
addCommand("addDevice", new AddDeviceCommand());
|
addCommand("addDevice", new AddDeviceCommand());
|
||||||
addCommand("daemon", new DaemonCommand());
|
addCommand("daemon", new DaemonCommand());
|
||||||
addCommand("link", new LinkCommand());
|
addCommand("link", new LinkCommand());
|
||||||
|
addCommand("listContacts", new ListContactsCommand());
|
||||||
addCommand("listDevices", new ListDevicesCommand());
|
addCommand("listDevices", new ListDevicesCommand());
|
||||||
addCommand("listGroups", new ListGroupsCommand());
|
addCommand("listGroups", new ListGroupsCommand());
|
||||||
addCommand("listIdentities", new ListIdentitiesCommand());
|
addCommand("listIdentities", new ListIdentitiesCommand());
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package org.asamk.signal.commands;
|
||||||
|
|
||||||
|
import net.sourceforge.argparse4j.inf.Namespace;
|
||||||
|
import net.sourceforge.argparse4j.inf.Subparser;
|
||||||
|
|
||||||
|
import org.asamk.signal.manager.Manager;
|
||||||
|
import org.asamk.signal.storage.contacts.ContactInfo;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ListContactsCommand implements LocalCommand {
|
||||||
|
@Override
|
||||||
|
public void attachToSubparser(final Subparser subparser) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int handleCommand(final Namespace ns, final Manager m) {
|
||||||
|
if (!m.isRegistered()) {
|
||||||
|
System.err.println("User is not registered.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
List<ContactInfo> contacts = m.getContacts();
|
||||||
|
for (ContactInfo c : contacts) {
|
||||||
|
System.out.println(String.format("Number: %s Name: %s", c.number, c.name));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1484,6 +1484,10 @@ public class Manager implements Signal {
|
||||||
sendSyncMessage(SignalServiceSyncMessage.forVerified(verifiedMessage));
|
sendSyncMessage(SignalServiceSyncMessage.forVerified(verifiedMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ContactInfo> getContacts() {
|
||||||
|
return account.getContactStore().getContacts();
|
||||||
|
}
|
||||||
|
|
||||||
public ContactInfo getContact(String number) {
|
public ContactInfo getContact(String number) {
|
||||||
return account.getContactStore().getContact(number);
|
return account.getContactStore().getContact(number);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue