]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/commands/Commands.java
Implement change phone number
[signal-cli] / src / main / java / org / asamk / signal / commands / Commands.java
index ed2796b82fdfb5897021ccc1c89528461ce7ad9e..719ba132ac681f4857b6fb87c09e7bcf658fdcbd 100644 (file)
@@ -2,40 +2,78 @@ package org.asamk.signal.commands;
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.TreeMap;
 
 public class Commands {
 
     private static final Map<String, Command> commands = new HashMap<>();
+    private static final Map<String, SubparserAttacher> commandSubparserAttacher = new TreeMap<>();
 
     static {
-        addCommand("addDevice", new AddDeviceCommand());
-        addCommand("daemon", new DaemonCommand());
-        addCommand("link", new LinkCommand());
-        addCommand("listDevices", new ListDevicesCommand());
-        addCommand("listGroups", new ListGroupsCommand());
-        addCommand("listIdentities", new ListIdentitiesCommand());
-        addCommand("quitGroup", new QuitGroupCommand());
-        addCommand("receive", new ReceiveCommand());
-        addCommand("register", new RegisterCommand());
-        addCommand("removeDevice", new RemoveDeviceCommand());
-        addCommand("removePin", new RemovePinCommand());
-        addCommand("send", new SendCommand());
-        addCommand("sendContacts", new SendContactsCommand());
-        addCommand("setContactName", new SetContactNameCommand());
-        addCommand("setPin", new SetPinCommand());
-        addCommand("trust", new TrustCommand());
-        addCommand("unregister", new UnregisterCommand());
-        addCommand("updateAccount", new UpdateAccountCommand());
-        addCommand("updateGroup", new UpdateGroupCommand());
-        addCommand("updateProfile", new UpdateProfileCommand());
-        addCommand("verify", new VerifyCommand());
+        addCommand(new AddDeviceCommand());
+        addCommand(new BlockCommand());
+        addCommand(new DaemonCommand());
+        addCommand(new DeleteLocalAccountDataCommand());
+        addCommand(new FinishChangeNumberCommand());
+        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 StartChangeNumberCommand());
+        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<String, Command> getCommands() {
-        return commands;
+    public static Map<String, SubparserAttacher> getCommandSubparserAttachers() {
+        return commandSubparserAttacher;
     }
 
-    private static void addCommand(String name, Command command) {
-        commands.put(name, command);
+    public static Command getCommand(String commandKey) {
+        if (!commands.containsKey(commandKey)) {
+            return null;
+        }
+        return commands.get(commandKey);
+    }
+
+    private static void addCommand(Command command) {
+        commands.put(command.getName(), command);
+        if (command instanceof CliCommand) {
+            commandSubparserAttacher.put(command.getName(), ((CliCommand) command)::attachToSubparser);
+        }
     }
 }