mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-02 12:30:39 +00:00
Re-enabled --json for receive and getUserStatuses commands as deprecated
This commit is contained in:
parent
f4df26de7b
commit
eb401df4a2
2 changed files with 20 additions and 3 deletions
|
@ -21,6 +21,9 @@ public class GetUserStatusCommand implements LocalCommand {
|
||||||
public void attachToSubparser(final Subparser subparser) {
|
public void attachToSubparser(final Subparser subparser) {
|
||||||
subparser.addArgument("number").help("Phone number").nargs("+");
|
subparser.addArgument("number").help("Phone number").nargs("+");
|
||||||
subparser.help("Check if the specified phone number/s have been registered");
|
subparser.help("Check if the specified phone number/s have been registered");
|
||||||
|
subparser.addArgument("--json")
|
||||||
|
.help("WARNING: This parameter is now deprecated! Please use the \"output\" option instead.\n\nOutput received messages in json format, one json object per line.")
|
||||||
|
.action(Arguments.storeTrue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -38,8 +41,14 @@ public class GetUserStatusCommand implements LocalCommand {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean inJson = ns.getString("output").equals("json");
|
||||||
|
if (ns.getBoolean("json")) {
|
||||||
|
inJson = true;
|
||||||
|
System.out.println("WARNING: This parameter is now deprecated! Please use the \"output\" parameter instead.");
|
||||||
|
}
|
||||||
|
|
||||||
// Output
|
// Output
|
||||||
if (ns.getString("output").equals("json")) {
|
if (inJson) {
|
||||||
List<JsonIsRegistered> objects = registered.entrySet()
|
List<JsonIsRegistered> objects = registered.entrySet()
|
||||||
.stream()
|
.stream()
|
||||||
.map(entry -> new JsonIsRegistered(entry.getKey(), entry.getValue()))
|
.map(entry -> new JsonIsRegistered(entry.getKey(), entry.getValue()))
|
||||||
|
|
|
@ -35,11 +35,17 @@ public class ReceiveCommand implements ExtendedDbusCommand, LocalCommand {
|
||||||
subparser.addArgument("--ignore-attachments")
|
subparser.addArgument("--ignore-attachments")
|
||||||
.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")
|
||||||
|
.help("WARNING: This parameter is now deprecated! Please use the \"output\" option instead.\n\nOutput received messages in json format, one json object per line.")
|
||||||
|
.action(Arguments.storeTrue());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int handleCommand(final Namespace ns, final Signal signal, DBusConnection dbusconnection) {
|
public int handleCommand(final Namespace ns, final Signal signal, DBusConnection dbusconnection) {
|
||||||
final ObjectMapper jsonProcessor;
|
final ObjectMapper jsonProcessor;
|
||||||
if (ns.getString("output").equals("json")) {
|
|
||||||
|
boolean inJson = ns.getString("output").equals("json") || ns.getBoolean("json");
|
||||||
|
|
||||||
|
if (inJson) {
|
||||||
jsonProcessor = new ObjectMapper();
|
jsonProcessor = new ObjectMapper();
|
||||||
jsonProcessor.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
jsonProcessor.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||||
jsonProcessor.disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET);
|
jsonProcessor.disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET);
|
||||||
|
@ -143,6 +149,8 @@ public class ReceiveCommand implements ExtendedDbusCommand, LocalCommand {
|
||||||
|
|
||||||
@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");
|
||||||
|
|
||||||
double timeout = 5;
|
double timeout = 5;
|
||||||
if (ns.getDouble("timeout") != null) {
|
if (ns.getDouble("timeout") != null) {
|
||||||
timeout = ns.getDouble("timeout");
|
timeout = ns.getDouble("timeout");
|
||||||
|
@ -154,7 +162,7 @@ public class ReceiveCommand implements ExtendedDbusCommand, LocalCommand {
|
||||||
}
|
}
|
||||||
boolean ignoreAttachments = ns.getBoolean("ignore_attachments");
|
boolean ignoreAttachments = ns.getBoolean("ignore_attachments");
|
||||||
try {
|
try {
|
||||||
final Manager.ReceiveMessageHandler handler = ns.getString("output").equals("json")
|
final Manager.ReceiveMessageHandler handler = inJson
|
||||||
? new JsonReceiveMessageHandler(m)
|
? new JsonReceiveMessageHandler(m)
|
||||||
: new ReceiveMessageHandler(m);
|
: new ReceiveMessageHandler(m);
|
||||||
m.receiveMessages((long) (timeout * 1000),
|
m.receiveMessages((long) (timeout * 1000),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue