mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Move Writer creation out of WriterImpls
This commit is contained in:
parent
b5eef3ccad
commit
5dd602614c
4 changed files with 23 additions and 22 deletions
|
@ -32,8 +32,11 @@ import org.freedesktop.dbus.exceptions.DBusExecutionException;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -105,9 +108,10 @@ public class App {
|
|||
var outputType = outputTypeInput == null
|
||||
? command.getSupportedOutputTypes().stream().findFirst().orElse(null)
|
||||
: outputTypeInput;
|
||||
var writer = new BufferedWriter(new OutputStreamWriter(System.out, Charset.defaultCharset()));
|
||||
var outputWriter = outputType == null
|
||||
? null
|
||||
: outputType == OutputType.JSON ? new JsonWriterImpl(System.out) : new PlainTextWriterImpl(System.out);
|
||||
: outputType == OutputType.JSON ? new JsonWriterImpl(writer) : new PlainTextWriterImpl(writer);
|
||||
|
||||
if (outputWriter != null && !command.getSupportedOutputTypes().contains(outputType)) {
|
||||
throw new UserErrorException("Command doesn't support output type " + outputType);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue