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
|
@ -4,10 +4,14 @@ import net.sourceforge.argparse4j.inf.Namespace;
|
|||
import net.sourceforge.argparse4j.inf.Subparser;
|
||||
|
||||
import org.asamk.Signal;
|
||||
import org.asamk.signal.PlainTextWriterImpl;
|
||||
import org.asamk.signal.manager.groups.GroupIdFormatException;
|
||||
import org.asamk.signal.util.Util;
|
||||
import org.freedesktop.dbus.exceptions.DBusExecutionException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
@ -17,6 +21,8 @@ import static org.asamk.signal.util.ErrorUtils.handleGroupIdFormatException;
|
|||
|
||||
public class UpdateGroupCommand implements DbusCommand {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(UpdateGroupCommand.class);
|
||||
|
||||
@Override
|
||||
public void attachToSubparser(final Subparser subparser) {
|
||||
subparser.addArgument("-g", "--group").help("Specify the recipient group ID.");
|
||||
|
@ -27,6 +33,7 @@ public class UpdateGroupCommand implements DbusCommand {
|
|||
|
||||
@Override
|
||||
public int handleCommand(final Namespace ns, final Signal signal) {
|
||||
final var writer = new PlainTextWriterImpl(System.out);
|
||||
byte[] groupId = null;
|
||||
if (ns.getString("group") != null) {
|
||||
try {
|
||||
|
@ -58,7 +65,12 @@ public class UpdateGroupCommand implements DbusCommand {
|
|||
try {
|
||||
var newGroupId = signal.updateGroup(groupId, groupName, groupMembers, groupAvatar);
|
||||
if (groupId.length != newGroupId.length) {
|
||||
System.out.println("Creating new group \"" + Base64.getEncoder().encodeToString(newGroupId) + "\" …");
|
||||
try {
|
||||
writer.println("Creating new group \"{}\" …", Base64.getEncoder().encodeToString(newGroupId));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
} catch (AssertionError e) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue