mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Use global output flag for daemon command
This commit is contained in:
parent
5938d54784
commit
cc40c437d1
1 changed files with 13 additions and 2 deletions
|
@ -10,6 +10,8 @@ import org.asamk.signal.dbus.DbusSignalImpl;
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.freedesktop.dbus.connections.impl.DBusConnection;
|
import org.freedesktop.dbus.connections.impl.DBusConnection;
|
||||||
import org.freedesktop.dbus.exceptions.DBusException;
|
import org.freedesktop.dbus.exceptions.DBusException;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -20,6 +22,8 @@ import static org.asamk.signal.util.ErrorUtils.handleAssertionError;
|
||||||
|
|
||||||
public class DaemonCommand implements LocalCommand {
|
public class DaemonCommand implements LocalCommand {
|
||||||
|
|
||||||
|
private final static Logger logger = LoggerFactory.getLogger(ReceiveCommand.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void attachToSubparser(final Subparser subparser) {
|
public void attachToSubparser(final Subparser subparser) {
|
||||||
subparser.addArgument("--system")
|
subparser.addArgument("--system")
|
||||||
|
@ -29,12 +33,19 @@ public class DaemonCommand implements LocalCommand {
|
||||||
.help("Don’t download attachments of received messages.")
|
.help("Don’t download attachments of received messages.")
|
||||||
.action(Arguments.storeTrue());
|
.action(Arguments.storeTrue());
|
||||||
subparser.addArgument("--json")
|
subparser.addArgument("--json")
|
||||||
.help("Output received messages in json format, one json object per line.")
|
.help("WARNING: This parameter is now deprecated! Please use the global \"--output=json\" option instead.\n\nOutput received messages in json format, one json object per line.")
|
||||||
.action(Arguments.storeTrue());
|
.action(Arguments.storeTrue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int handleCommand(final Namespace ns, final Manager m) {
|
public int handleCommand(final Namespace ns, final Manager m) {
|
||||||
|
boolean inJson = ns.getString("output").equals("json") || ns.getBoolean("json");
|
||||||
|
|
||||||
|
// TODO delete later when "json" variable is removed
|
||||||
|
if (ns.getBoolean("json")) {
|
||||||
|
logger.warn("\"--json\" option has been deprecated, please use the global \"--output=json\" instead.");
|
||||||
|
}
|
||||||
|
|
||||||
DBusConnection conn = null;
|
DBusConnection conn = null;
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
|
@ -60,7 +71,7 @@ public class DaemonCommand implements LocalCommand {
|
||||||
TimeUnit.HOURS,
|
TimeUnit.HOURS,
|
||||||
false,
|
false,
|
||||||
ignoreAttachments,
|
ignoreAttachments,
|
||||||
ns.getBoolean("json")
|
inJson
|
||||||
? new JsonDbusReceiveMessageHandler(m, conn, SIGNAL_OBJECTPATH)
|
? new JsonDbusReceiveMessageHandler(m, conn, SIGNAL_OBJECTPATH)
|
||||||
: new DbusReceiveMessageHandler(m, conn, SIGNAL_OBJECTPATH));
|
: new DbusReceiveMessageHandler(m, conn, SIGNAL_OBJECTPATH));
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue