X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/a8bbdb54d006f157a009ece0cae5bf72fb636ced..7b5b5776f014db0ad18fb6af909c63bbf2293c88:/src/main/java/org/asamk/signal/commands/Commands.java diff --git a/src/main/java/org/asamk/signal/commands/Commands.java b/src/main/java/org/asamk/signal/commands/Commands.java index 33caf8ba..2783ca37 100644 --- a/src/main/java/org/asamk/signal/commands/Commands.java +++ b/src/main/java/org/asamk/signal/commands/Commands.java @@ -1,74 +1,77 @@ package org.asamk.signal.commands; -import org.asamk.signal.OutputWriter; - import java.util.HashMap; import java.util.Map; import java.util.TreeMap; public class Commands { - private static final Map commands = new HashMap<>(); + private static final Map commands = new HashMap<>(); private static final Map commandSubparserAttacher = new TreeMap<>(); static { - addCommand("addDevice", AddDeviceCommand::new, AddDeviceCommand::attachToSubparser); - addCommand("block", BlockCommand::new, BlockCommand::attachToSubparser); - addCommand("daemon", DaemonCommand::new, DaemonCommand::attachToSubparser); - addCommand("getUserStatus", GetUserStatusCommand::new, GetUserStatusCommand::attachToSubparser); - addCommand("jsonRpc", JsonRpcDispatcherCommand::new, JsonRpcDispatcherCommand::attachToSubparser); - addCommand("link", LinkCommand::new, LinkCommand::attachToSubparser); - addCommand("listContacts", ListContactsCommand::new, ListContactsCommand::attachToSubparser); - addCommand("listDevices", ListDevicesCommand::new, ListDevicesCommand::attachToSubparser); - addCommand("listGroups", ListGroupsCommand::new, ListGroupsCommand::attachToSubparser); - addCommand("listIdentities", ListIdentitiesCommand::new, ListIdentitiesCommand::attachToSubparser); - addCommand("joinGroup", JoinGroupCommand::new, JoinGroupCommand::attachToSubparser); - addCommand("quitGroup", QuitGroupCommand::new, QuitGroupCommand::attachToSubparser); - addCommand("receive", ReceiveCommand::new, ReceiveCommand::attachToSubparser); - addCommand("register", RegisterCommand::new, RegisterCommand::attachToSubparser); - addCommand("removeDevice", RemoveDeviceCommand::new, RemoveDeviceCommand::attachToSubparser); - addCommand("remoteDelete", RemoteDeleteCommand::new, RemoteDeleteCommand::attachToSubparser); - addCommand("removePin", RemovePinCommand::new, RemovePinCommand::attachToSubparser); - addCommand("send", SendCommand::new, SendCommand::attachToSubparser); - addCommand("sendContacts", SendContactsCommand::new, SendContactsCommand::attachToSubparser); - addCommand("sendReaction", SendReactionCommand::new, SendReactionCommand::attachToSubparser); - addCommand("sendSyncRequest", SendSyncRequestCommand::new, SendSyncRequestCommand::attachToSubparser); - addCommand("sendTyping", SendTypingCommand::new, SendTypingCommand::attachToSubparser); - addCommand("setPin", SetPinCommand::new, SetPinCommand::attachToSubparser); - addCommand("trust", TrustCommand::new, TrustCommand::attachToSubparser); - addCommand("unblock", UnblockCommand::new, UnblockCommand::attachToSubparser); - addCommand("unregister", UnregisterCommand::new, UnregisterCommand::attachToSubparser); - addCommand("updateAccount", UpdateAccountCommand::new, UpdateAccountCommand::attachToSubparser); - addCommand("updateContact", UpdateContactCommand::new, UpdateContactCommand::attachToSubparser); - addCommand("updateGroup", UpdateGroupCommand::new, UpdateGroupCommand::attachToSubparser); - addCommand("updateProfile", UpdateProfileCommand::new, UpdateProfileCommand::attachToSubparser); - addCommand("uploadStickerPack", UploadStickerPackCommand::new, UploadStickerPackCommand::attachToSubparser); - addCommand("verify", VerifyCommand::new, VerifyCommand::attachToSubparser); - addCommand("version", VersionCommand::new, null); + addCommand(new AddDeviceCommand()); + addCommand(new BlockCommand()); + addCommand(new DaemonCommand()); + addCommand(new DeleteLocalAccountDataCommand()); + addCommand(new FinishLinkCommand()); + addCommand(new GetAttachmentCommand()); + addCommand(new GetUserStatusCommand()); + addCommand(new AddStickerPackCommand()); + addCommand(new JoinGroupCommand()); + addCommand(new JsonRpcDispatcherCommand()); + addCommand(new LinkCommand()); + addCommand(new ListAccountsCommand()); + addCommand(new ListContactsCommand()); + addCommand(new ListDevicesCommand()); + addCommand(new ListGroupsCommand()); + addCommand(new ListIdentitiesCommand()); + addCommand(new ListStickerPacksCommand()); + addCommand(new QuitGroupCommand()); + addCommand(new ReceiveCommand()); + addCommand(new RegisterCommand()); + addCommand(new RemoveContactCommand()); + addCommand(new RemoveDeviceCommand()); + addCommand(new RemovePinCommand()); + addCommand(new RemoteDeleteCommand()); + addCommand(new SendCommand()); + addCommand(new SendContactsCommand()); + addCommand(new SendPaymentNotificationCommand()); + addCommand(new SendReactionCommand()); + addCommand(new SendReceiptCommand()); + addCommand(new SendSyncRequestCommand()); + addCommand(new SendTypingCommand()); + addCommand(new SetPinCommand()); + addCommand(new SubmitRateLimitChallengeCommand()); + addCommand(new StartLinkCommand()); + addCommand(new TrustCommand()); + addCommand(new UnblockCommand()); + addCommand(new UnregisterCommand()); + addCommand(new UpdateAccountCommand()); + addCommand(new UpdateConfigurationCommand()); + addCommand(new UpdateContactCommand()); + addCommand(new UpdateGroupCommand()); + addCommand(new UpdateProfileCommand()); + addCommand(new UploadStickerPackCommand()); + addCommand(new VerifyCommand()); + addCommand(new VersionCommand()); } public static Map getCommandSubparserAttachers() { return commandSubparserAttacher; } - public static Command getCommand(String commandKey, OutputWriter outputWriter) { + public static Command getCommand(String commandKey) { if (!commands.containsKey(commandKey)) { return null; } - return commands.get(commandKey).constructCommand(outputWriter); + return commands.get(commandKey); } - private static void addCommand( - String name, CommandConstructor commandConstructor, SubparserAttacher subparserAttacher - ) { - commands.put(name, commandConstructor); - if (subparserAttacher != null) { - commandSubparserAttacher.put(name, subparserAttacher); + private static void addCommand(Command command) { + commands.put(command.getName(), command); + if (command instanceof CliCommand) { + commandSubparserAttacher.put(command.getName(), ((CliCommand) command)::attachToSubparser); } } - - private interface CommandConstructor { - - Command constructCommand(OutputWriter outputWriter); - } }