mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Use PlainTextWriter for all cli stdout output
This commit is contained in:
parent
de273586b4
commit
c6395b9f35
14 changed files with 220 additions and 99 deletions
|
@ -3,9 +3,12 @@ package org.asamk.signal.commands;
|
|||
import net.sourceforge.argparse4j.inf.Namespace;
|
||||
import net.sourceforge.argparse4j.inf.Subparser;
|
||||
|
||||
import org.asamk.signal.PlainTextWriterImpl;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.groups.GroupInviteLinkUrl;
|
||||
import org.freedesktop.dbus.exceptions.DBusExecutionException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.whispersystems.signalservice.api.groupsv2.GroupLinkNotActiveException;
|
||||
import org.whispersystems.signalservice.internal.push.exceptions.GroupPatchNotAcceptedException;
|
||||
|
||||
|
@ -17,6 +20,8 @@ import static org.asamk.signal.util.ErrorUtils.handleTimestampAndSendMessageResu
|
|||
|
||||
public class JoinGroupCommand implements LocalCommand {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(JoinGroupCommand.class);
|
||||
|
||||
@Override
|
||||
public void attachToSubparser(final Subparser subparser) {
|
||||
subparser.addArgument("--uri").required(true).help("Specify the uri with the group invitation link.");
|
||||
|
@ -42,14 +47,16 @@ public class JoinGroupCommand implements LocalCommand {
|
|||
}
|
||||
|
||||
try {
|
||||
final var writer = new PlainTextWriterImpl(System.out);
|
||||
|
||||
final var results = m.joinGroup(linkUrl);
|
||||
var newGroupId = results.first();
|
||||
if (!m.getGroup(newGroupId).isMember(m.getSelfAddress())) {
|
||||
System.out.println("Requested to join group \"" + newGroupId.toBase64() + "\"");
|
||||
writer.println("Requested to join group \"{}\"", newGroupId.toBase64());
|
||||
} else {
|
||||
System.out.println("Joined group \"" + newGroupId.toBase64() + "\"");
|
||||
writer.println("Joined group \"{}\"", newGroupId.toBase64());
|
||||
}
|
||||
return handleTimestampAndSendMessageResults(0, results.second());
|
||||
return handleTimestampAndSendMessageResults(writer, 0, results.second());
|
||||
} catch (AssertionError e) {
|
||||
handleAssertionError(e);
|
||||
return 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue