Align cli param names for recipient

This commit is contained in:
AsamK 2021-08-25 21:21:12 +02:00
parent ca52c01031
commit 95792be9bc
6 changed files with 17 additions and 15 deletions

View file

@ -25,7 +25,7 @@ public class BlockCommand implements JsonRpcLocalCommand {
@Override @Override
public void attachToSubparser(final Subparser subparser) { public void attachToSubparser(final Subparser subparser) {
subparser.help("Block the given contacts or groups (no messages will be received)"); 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("*"); subparser.addArgument("-g", "--group-id", "--group").help("Group ID").nargs("*");
} }
@ -33,7 +33,7 @@ public class BlockCommand implements JsonRpcLocalCommand {
public void handleCommand( public void handleCommand(
final Namespace ns, final Manager m, final OutputWriter outputWriter final Namespace ns, final Manager m, final OutputWriter outputWriter
) throws CommandException { ) throws CommandException {
final var contacts = ns.<String>getList("contact"); final var contacts = ns.<String>getList("recipient");
for (var contact : CommandUtil.getSingleRecipientIdentifiers(contacts, m.getUsername())) { for (var contact : CommandUtil.getSingleRecipientIdentifiers(contacts, m.getUsername())) {
try { try {
m.setContactBlocked(contact, true); m.setContactBlocked(contact, true);

View file

@ -31,7 +31,7 @@ public class GetUserStatusCommand implements JsonRpcLocalCommand {
@Override @Override
public void attachToSubparser(final Subparser subparser) { public void attachToSubparser(final Subparser subparser) {
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("number").help("Phone number").nargs("+"); subparser.addArgument("recipient").help("Phone number").nargs("+");
} }
@Override @Override
@ -41,7 +41,7 @@ public class GetUserStatusCommand implements JsonRpcLocalCommand {
// Get a map of registration statuses // Get a map of registration statuses
Map<String, Pair<String, UUID>> registered; Map<String, Pair<String, UUID>> registered;
try { try {
registered = m.areUsersRegistered(new HashSet<>(ns.getList("number"))); registered = m.areUsersRegistered(new HashSet<>(ns.getList("recipient")));
} catch (IOException e) { } catch (IOException e) {
logger.debug("Failed to check registered users", e); logger.debug("Failed to check registered users", e);
throw new IOErrorException("Unable to check if users are registered"); throw new IOErrorException("Unable to check if users are registered");
@ -69,7 +69,7 @@ public class GetUserStatusCommand implements JsonRpcLocalCommand {
private static final class JsonUserStatus { private static final class JsonUserStatus {
public final String name; public final String recipient;
public final String number; public final String number;
@ -77,8 +77,8 @@ public class GetUserStatusCommand implements JsonRpcLocalCommand {
public final boolean isRegistered; public final boolean isRegistered;
public JsonUserStatus(String name, String number, String uuid, boolean isRegistered) { public JsonUserStatus(String recipient, String number, String uuid, boolean isRegistered) {
this.name = name; this.recipient = recipient;
this.number = number; this.number = number;
this.uuid = uuid; this.uuid = uuid;
this.isRegistered = isRegistered; this.isRegistered = isRegistered;

View file

@ -27,7 +27,9 @@ public class SendReceiptCommand implements JsonRpcLocalCommand {
.type(long.class) .type(long.class)
.nargs("+") .nargs("+")
.help("Specify the timestamp of the messages for which a receipt should be sent."); .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 @Override
@ -41,7 +43,7 @@ public class SendReceiptCommand implements JsonRpcLocalCommand {
final var type = ns.getString("type"); final var type = ns.getString("type");
try { try {
if ("read".equals(type)) { if (type == null || "read".equals(type)) {
m.sendReadReceipt(recipient, targetTimestamps); m.sendReadReceipt(recipient, targetTimestamps);
} else if ("viewed".equals(type)) { } else if ("viewed".equals(type)) {
m.sendViewedReceipt(recipient, targetTimestamps); m.sendViewedReceipt(recipient, targetTimestamps);

View file

@ -24,7 +24,7 @@ public class TrustCommand implements JsonRpcLocalCommand {
@Override @Override
public void attachToSubparser(final Subparser subparser) { public void attachToSubparser(final Subparser subparser) {
subparser.help("Set the trust level of a given number."); 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(); var mutTrust = subparser.addMutuallyExclusiveGroup();
mutTrust.addArgument("-a", "--trust-all-known-keys") mutTrust.addArgument("-a", "--trust-all-known-keys")
.help("Trust all known keys of this user, only use this for testing.") .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( public void handleCommand(
final Namespace ns, final Manager m, final OutputWriter outputWriter final Namespace ns, final Manager m, final OutputWriter outputWriter
) throws CommandException { ) throws CommandException {
var recipentString = ns.getString("number"); var recipentString = ns.getString("recipient");
var recipient = CommandUtil.getSingleRecipientIdentifier(recipentString, m.getUsername()); var recipient = CommandUtil.getSingleRecipientIdentifier(recipentString, m.getUsername());
if (ns.getBoolean("trust-all-known-keys")) { if (ns.getBoolean("trust-all-known-keys")) {
boolean res = m.trustIdentityAllKeys(recipient); boolean res = m.trustIdentityAllKeys(recipient);

View file

@ -25,7 +25,7 @@ public class UnblockCommand implements JsonRpcLocalCommand {
@Override @Override
public void attachToSubparser(final Subparser subparser) { public void attachToSubparser(final Subparser subparser) {
subparser.help("Unblock the given contacts or groups (messages will be received again)"); 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("*"); subparser.addArgument("-g", "--group-id", "--group").help("Group ID").nargs("*");
} }
@ -33,7 +33,7 @@ public class UnblockCommand implements JsonRpcLocalCommand {
public void handleCommand( public void handleCommand(
final Namespace ns, final Manager m, final OutputWriter outputWriter final Namespace ns, final Manager m, final OutputWriter outputWriter
) throws CommandException { ) throws CommandException {
for (var contactNumber : CommandUtil.getSingleRecipientIdentifiers(ns.getList("contact"), m.getUsername())) { for (var contactNumber : CommandUtil.getSingleRecipientIdentifiers(ns.getList("recipient"), m.getUsername())) {
try { try {
m.setContactBlocked(contactNumber, false); m.setContactBlocked(contactNumber, false);
} catch (NotMasterDeviceException e) { } catch (NotMasterDeviceException e) {

View file

@ -23,7 +23,7 @@ public class UpdateContactCommand implements JsonRpcLocalCommand {
@Override @Override
public void attachToSubparser(final Subparser subparser) { public void attachToSubparser(final Subparser subparser) {
subparser.help("Update the details of a given contact"); 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("-n", "--name").help("New contact name");
subparser.addArgument("-e", "--expiration").type(int.class).help("Set expiration time of messages (seconds)"); 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( public void handleCommand(
final Namespace ns, final Manager m, final OutputWriter outputWriter final Namespace ns, final Manager m, final OutputWriter outputWriter
) throws CommandException { ) throws CommandException {
var recipientString = ns.getString("number"); var recipientString = ns.getString("recipient");
var recipient = CommandUtil.getSingleRecipientIdentifier(recipientString, m.getUsername()); var recipient = CommandUtil.getSingleRecipientIdentifier(recipientString, m.getUsername());
try { try {