]> nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/signal/commands/Commands.java
Cache group credentials in memory
[signal-cli] / src / main / java / org / asamk / signal / commands / Commands.java
1 package org.asamk.signal.commands;
2
3 import java.util.HashMap;
4 import java.util.Map;
5 import java.util.TreeMap;
6
7 public class Commands {
8
9 private static final Map<String, Command> commands = new HashMap<>();
10 private static final Map<String, SubparserAttacher> commandSubparserAttacher = new TreeMap<>();
11
12 static {
13 addCommand(new AddDeviceCommand());
14 addCommand(new BlockCommand());
15 addCommand(new DaemonCommand());
16 addCommand(new FinishLinkCommand());
17 addCommand(new GetUserStatusCommand());
18 addCommand(new JoinGroupCommand());
19 addCommand(new JsonRpcDispatcherCommand());
20 addCommand(new LinkCommand());
21 addCommand(new ListAccountsCommand());
22 addCommand(new ListContactsCommand());
23 addCommand(new ListDevicesCommand());
24 addCommand(new ListGroupsCommand());
25 addCommand(new ListIdentitiesCommand());
26 addCommand(new QuitGroupCommand());
27 addCommand(new ReceiveCommand());
28 addCommand(new RegisterCommand());
29 addCommand(new RemoveContactCommand());
30 addCommand(new RemoveDeviceCommand());
31 addCommand(new RemoteDeleteCommand());
32 addCommand(new RemovePinCommand());
33 addCommand(new SendCommand());
34 addCommand(new SendContactsCommand());
35 addCommand(new SendReactionCommand());
36 addCommand(new SendReceiptCommand());
37 addCommand(new SendSyncRequestCommand());
38 addCommand(new SendTypingCommand());
39 addCommand(new SetPinCommand());
40 addCommand(new SubmitRateLimitChallengeCommand());
41 addCommand(new StartLinkCommand());
42 addCommand(new TrustCommand());
43 addCommand(new UnblockCommand());
44 addCommand(new UnregisterCommand());
45 addCommand(new UpdateAccountCommand());
46 addCommand(new UpdateConfigurationCommand());
47 addCommand(new UpdateContactCommand());
48 addCommand(new UpdateGroupCommand());
49 addCommand(new UpdateProfileCommand());
50 addCommand(new UploadStickerPackCommand());
51 addCommand(new VerifyCommand());
52 addCommand(new VersionCommand());
53 }
54
55 public static Map<String, SubparserAttacher> getCommandSubparserAttachers() {
56 return commandSubparserAttacher;
57 }
58
59 public static Command getCommand(String commandKey) {
60 if (!commands.containsKey(commandKey)) {
61 return null;
62 }
63 return commands.get(commandKey);
64 }
65
66 private static void addCommand(Command command) {
67 commands.put(command.getName(), command);
68 if (command instanceof CliCommand) {
69 commandSubparserAttacher.put(command.getName(), ((CliCommand) command)::attachToSubparser);
70 }
71 }
72 }