mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-30 11:00:38 +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,8 +3,11 @@ 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.ProvisioningManager;
|
||||
import org.asamk.signal.manager.UserAlreadyExists;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.whispersystems.libsignal.InvalidKeyException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -14,6 +17,8 @@ import static org.asamk.signal.util.ErrorUtils.handleAssertionError;
|
|||
|
||||
public class LinkCommand implements ProvisioningCommand {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(LinkCommand.class);
|
||||
|
||||
@Override
|
||||
public void attachToSubparser(final Subparser subparser) {
|
||||
subparser.addArgument("-n", "--name").help("Specify a name to describe this new device.");
|
||||
|
@ -21,14 +26,16 @@ public class LinkCommand implements ProvisioningCommand {
|
|||
|
||||
@Override
|
||||
public int handleCommand(final Namespace ns, final ProvisioningManager m) {
|
||||
final var writer = new PlainTextWriterImpl(System.out);
|
||||
|
||||
var deviceName = ns.getString("name");
|
||||
if (deviceName == null) {
|
||||
deviceName = "cli";
|
||||
}
|
||||
try {
|
||||
System.out.println(m.getDeviceLinkUri());
|
||||
writer.println("{}", m.getDeviceLinkUri());
|
||||
var username = m.finishDeviceLink(deviceName);
|
||||
System.out.println("Associated with: " + username);
|
||||
writer.println("Associated with: {}", username);
|
||||
} catch (TimeoutException e) {
|
||||
System.err.println("Link request timed out, please try again.");
|
||||
return 3;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue