]> nmode's Git Repositories - signal-cli/commitdiff
Align cli param names for recipient
authorAsamK <asamk@gmx.de>
Wed, 25 Aug 2021 19:21:12 +0000 (21:21 +0200)
committerAsamK <asamk@gmx.de>
Wed, 25 Aug 2021 19:21:19 +0000 (21:21 +0200)
src/main/java/org/asamk/signal/commands/BlockCommand.java
src/main/java/org/asamk/signal/commands/GetUserStatusCommand.java
src/main/java/org/asamk/signal/commands/SendReceiptCommand.java
src/main/java/org/asamk/signal/commands/TrustCommand.java
src/main/java/org/asamk/signal/commands/UnblockCommand.java
src/main/java/org/asamk/signal/commands/UpdateContactCommand.java

index 7326c398f3640535fe8c45566e4b6a9cfb823671..105c2016969d89066fb12adee15e92a4b6a36fac 100644 (file)
@@ -25,7 +25,7 @@ public class BlockCommand implements JsonRpcLocalCommand {
     @Override
     public void attachToSubparser(final Subparser subparser) {
         subparser.help("Block the given contacts or groups (no messages will be received)");
-        subparser.addArgument("contact").help("Contact number").nargs("*");
+        subparser.addArgument("recipient").help("Contact number").nargs("*");
         subparser.addArgument("-g", "--group-id", "--group").help("Group ID").nargs("*");
     }
 
@@ -33,7 +33,7 @@ public class BlockCommand implements JsonRpcLocalCommand {
     public void handleCommand(
             final Namespace ns, final Manager m, final OutputWriter outputWriter
     ) throws CommandException {
-        final var contacts = ns.<String>getList("contact");
+        final var contacts = ns.<String>getList("recipient");
         for (var contact : CommandUtil.getSingleRecipientIdentifiers(contacts, m.getUsername())) {
             try {
                 m.setContactBlocked(contact, true);
index 055dac9f4a7adc4f30a454e27e6e106da564232b..cf4be085cfb9031068da26ff7e3f861a8f3d4be1 100644 (file)
@@ -31,7 +31,7 @@ public class GetUserStatusCommand implements JsonRpcLocalCommand {
     @Override
     public void attachToSubparser(final Subparser subparser) {
         subparser.help("Check if the specified phone number/s have been registered");
-        subparser.addArgument("number").help("Phone number").nargs("+");
+        subparser.addArgument("recipient").help("Phone number").nargs("+");
     }
 
     @Override
@@ -41,7 +41,7 @@ public class GetUserStatusCommand implements JsonRpcLocalCommand {
         // Get a map of registration statuses
         Map<String, Pair<String, UUID>> registered;
         try {
-            registered = m.areUsersRegistered(new HashSet<>(ns.getList("number")));
+            registered = m.areUsersRegistered(new HashSet<>(ns.getList("recipient")));
         } catch (IOException e) {
             logger.debug("Failed to check registered users", e);
             throw new IOErrorException("Unable to check if users are registered");
@@ -69,7 +69,7 @@ public class GetUserStatusCommand implements JsonRpcLocalCommand {
 
     private static final class JsonUserStatus {
 
-        public final String name;
+        public final String recipient;
 
         public final String number;
 
@@ -77,8 +77,8 @@ public class GetUserStatusCommand implements JsonRpcLocalCommand {
 
         public final boolean isRegistered;
 
-        public JsonUserStatus(String name, String number, String uuid, boolean isRegistered) {
-            this.name = name;
+        public JsonUserStatus(String recipient, String number, String uuid, boolean isRegistered) {
+            this.recipient = recipient;
             this.number = number;
             this.uuid = uuid;
             this.isRegistered = isRegistered;
index afdbd4f8137a60477b00328afc69bdac80b7bba6..70e2f015adc5f4fa8dd798815ada7081c8be5782 100644 (file)
@@ -27,7 +27,9 @@ public class SendReceiptCommand implements JsonRpcLocalCommand {
                 .type(long.class)
                 .nargs("+")
                 .help("Specify the timestamp of the messages for which a receipt should be sent.");
-        subparser.addArgument("--type").help("Specify the receipt type.").choices("read", "viewed").setDefault("read");
+        subparser.addArgument("--type")
+                .help("Specify the receipt type (default is read receipt).")
+                .choices("read", "viewed");
     }
 
     @Override
@@ -41,7 +43,7 @@ public class SendReceiptCommand implements JsonRpcLocalCommand {
         final var type = ns.getString("type");
 
         try {
-            if ("read".equals(type)) {
+            if (type == null || "read".equals(type)) {
                 m.sendReadReceipt(recipient, targetTimestamps);
             } else if ("viewed".equals(type)) {
                 m.sendViewedReceipt(recipient, targetTimestamps);
index 22dcc5d8fcc3426d3cea83b5d328cf7a0efe27e3..aedc2c3e6e48643e14180bc91660d584101ac0cb 100644 (file)
@@ -24,7 +24,7 @@ public class TrustCommand implements JsonRpcLocalCommand {
     @Override
     public void attachToSubparser(final Subparser subparser) {
         subparser.help("Set the trust level of a given number.");
-        subparser.addArgument("number").help("Specify the phone number, for which to set the trust.").required(true);
+        subparser.addArgument("recipient").help("Specify the phone number, for which to set the trust.").required(true);
         var mutTrust = subparser.addMutuallyExclusiveGroup();
         mutTrust.addArgument("-a", "--trust-all-known-keys")
                 .help("Trust all known keys of this user, only use this for testing.")
@@ -37,7 +37,7 @@ public class TrustCommand implements JsonRpcLocalCommand {
     public void handleCommand(
             final Namespace ns, final Manager m, final OutputWriter outputWriter
     ) throws CommandException {
-        var recipentString = ns.getString("number");
+        var recipentString = ns.getString("recipient");
         var recipient = CommandUtil.getSingleRecipientIdentifier(recipentString, m.getUsername());
         if (ns.getBoolean("trust-all-known-keys")) {
             boolean res = m.trustIdentityAllKeys(recipient);
index c5b9d1cafbdb81415d964f2118fe82b19cbf250a..e931a60ee543958ef638931be21c0d1c9b6a6025 100644 (file)
@@ -25,7 +25,7 @@ public class UnblockCommand implements JsonRpcLocalCommand {
     @Override
     public void attachToSubparser(final Subparser subparser) {
         subparser.help("Unblock the given contacts or groups (messages will be received again)");
-        subparser.addArgument("contact").help("Contact number").nargs("*");
+        subparser.addArgument("recipient").help("Contact number").nargs("*");
         subparser.addArgument("-g", "--group-id", "--group").help("Group ID").nargs("*");
     }
 
@@ -33,7 +33,7 @@ public class UnblockCommand implements JsonRpcLocalCommand {
     public void handleCommand(
             final Namespace ns, final Manager m, final OutputWriter outputWriter
     ) throws CommandException {
-        for (var contactNumber : CommandUtil.getSingleRecipientIdentifiers(ns.getList("contact"), m.getUsername())) {
+        for (var contactNumber : CommandUtil.getSingleRecipientIdentifiers(ns.getList("recipient"), m.getUsername())) {
             try {
                 m.setContactBlocked(contactNumber, false);
             } catch (NotMasterDeviceException e) {
index 2b7d5b4b5612e683d515cccd680398883f702347..8b9f9aa5db4543ec2ac8916da2f1b3854a2a3b58 100644 (file)
@@ -23,7 +23,7 @@ public class UpdateContactCommand implements JsonRpcLocalCommand {
     @Override
     public void attachToSubparser(final Subparser subparser) {
         subparser.help("Update the details of a given contact");
-        subparser.addArgument("number").help("Contact number");
+        subparser.addArgument("recipient").help("Contact number");
         subparser.addArgument("-n", "--name").help("New contact name");
         subparser.addArgument("-e", "--expiration").type(int.class).help("Set expiration time of messages (seconds)");
     }
@@ -32,7 +32,7 @@ public class UpdateContactCommand implements JsonRpcLocalCommand {
     public void handleCommand(
             final Namespace ns, final Manager m, final OutputWriter outputWriter
     ) throws CommandException {
-        var recipientString = ns.getString("number");
+        var recipientString = ns.getString("recipient");
         var recipient = CommandUtil.getSingleRecipientIdentifier(recipientString, m.getUsername());
 
         try {