Use PlainTextWriter for all cli stdout output

This commit is contained in:
AsamK 2021-02-22 19:16:51 +01:00
parent de273586b4
commit c6395b9f35
14 changed files with 220 additions and 99 deletions

View file

@ -3,14 +3,19 @@ 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.StickerPackInvalidException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
public class UploadStickerPackCommand implements LocalCommand {
private final static Logger logger = LoggerFactory.getLogger(UploadStickerPackCommand.class);
@Override
public void attachToSubparser(final Subparser subparser) {
subparser.addArgument("path")
@ -19,10 +24,11 @@ public class UploadStickerPackCommand implements LocalCommand {
@Override
public int handleCommand(final Namespace ns, final Manager m) {
final var writer = new PlainTextWriterImpl(System.out);
try {
var path = new File(ns.getString("path"));
var url = m.uploadStickerPack(path);
System.out.println(url);
writer.println("{}", url);
return 0;
} catch (IOException e) {
System.err.println("Upload error: " + e.getMessage());