1 package org
.asamk
.signal
.commands
;
3 import org
.asamk
.signal
.OutputWriter
;
5 import java
.util
.HashMap
;
7 import java
.util
.TreeMap
;
9 public class Commands
{
11 private static final Map
<String
, CommandConstructor
> commands
= new HashMap
<>();
12 private static final Map
<String
, SubparserAttacher
> commandSubparserAttacher
= new TreeMap
<>();
15 addCommand("addDevice", AddDeviceCommand
::new, AddDeviceCommand
::attachToSubparser
);
16 addCommand("block", BlockCommand
::new, BlockCommand
::attachToSubparser
);
17 addCommand("daemon", DaemonCommand
::new, DaemonCommand
::attachToSubparser
);
18 addCommand("getUserStatus", GetUserStatusCommand
::new, GetUserStatusCommand
::attachToSubparser
);
19 addCommand("link", LinkCommand
::new, LinkCommand
::attachToSubparser
);
20 addCommand("listContacts", ListContactsCommand
::new, ListContactsCommand
::attachToSubparser
);
21 addCommand("listDevices", ListDevicesCommand
::new, ListDevicesCommand
::attachToSubparser
);
22 addCommand("listGroups", ListGroupsCommand
::new, ListGroupsCommand
::attachToSubparser
);
23 addCommand("listIdentities", ListIdentitiesCommand
::new, ListIdentitiesCommand
::attachToSubparser
);
24 addCommand("joinGroup", JoinGroupCommand
::new, JoinGroupCommand
::attachToSubparser
);
25 addCommand("quitGroup", QuitGroupCommand
::new, QuitGroupCommand
::attachToSubparser
);
26 addCommand("receive", ReceiveCommand
::new, ReceiveCommand
::attachToSubparser
);
27 addCommand("register", RegisterCommand
::new, RegisterCommand
::attachToSubparser
);
28 addCommand("removeDevice", RemoveDeviceCommand
::new, RemoveDeviceCommand
::attachToSubparser
);
29 addCommand("remoteDelete", RemoteDeleteCommand
::new, RemoteDeleteCommand
::attachToSubparser
);
30 addCommand("removePin", RemovePinCommand
::new, RemovePinCommand
::attachToSubparser
);
31 addCommand("send", SendCommand
::new, SendCommand
::attachToSubparser
);
32 addCommand("sendContacts", SendContactsCommand
::new, SendContactsCommand
::attachToSubparser
);
33 addCommand("sendReaction", SendReactionCommand
::new, SendReactionCommand
::attachToSubparser
);
34 addCommand("sendSyncRequest", SendSyncRequestCommand
::new, SendSyncRequestCommand
::attachToSubparser
);
35 addCommand("sendTyping", SendTypingCommand
::new, SendTypingCommand
::attachToSubparser
);
36 addCommand("setPin", SetPinCommand
::new, SetPinCommand
::attachToSubparser
);
37 addCommand("trust", TrustCommand
::new, TrustCommand
::attachToSubparser
);
38 addCommand("unblock", UnblockCommand
::new, UnblockCommand
::attachToSubparser
);
39 addCommand("unregister", UnregisterCommand
::new, UnregisterCommand
::attachToSubparser
);
40 addCommand("updateAccount", UpdateAccountCommand
::new, UpdateAccountCommand
::attachToSubparser
);
41 addCommand("updateContact", UpdateContactCommand
::new, UpdateContactCommand
::attachToSubparser
);
42 addCommand("updateGroup", UpdateGroupCommand
::new, UpdateGroupCommand
::attachToSubparser
);
43 addCommand("updateProfile", UpdateProfileCommand
::new, UpdateProfileCommand
::attachToSubparser
);
44 addCommand("uploadStickerPack", UploadStickerPackCommand
::new, UploadStickerPackCommand
::attachToSubparser
);
45 addCommand("verify", VerifyCommand
::new, VerifyCommand
::attachToSubparser
);
48 public static Map
<String
, SubparserAttacher
> getCommandSubparserAttachers() {
49 return commandSubparserAttacher
;
52 public static Command
getCommand(String commandKey
, OutputWriter outputWriter
) {
53 if (!commands
.containsKey(commandKey
)) {
56 return commands
.get(commandKey
).constructCommand(outputWriter
);
59 private static void addCommand(
60 String name
, CommandConstructor commandConstructor
, SubparserAttacher subparserAttacher
62 commands
.put(name
, commandConstructor
);
63 commandSubparserAttacher
.put(name
, subparserAttacher
);
66 private interface CommandConstructor
{
68 Command
constructCommand(OutputWriter outputWriter
);