]> nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/signal/commands/Commands.java
Implement exit code for rate limiting error
[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 DeleteLocalAccountDataCommand());
17 addCommand(new FinishLinkCommand());
18 addCommand(new GetAttachmentCommand());
19 addCommand(new GetUserStatusCommand());
20 addCommand(new AddStickerPackCommand());
21 addCommand(new JoinGroupCommand());
22 addCommand(new JsonRpcDispatcherCommand());
23 addCommand(new LinkCommand());
24 addCommand(new ListAccountsCommand());
25 addCommand(new ListContactsCommand());
26 addCommand(new ListDevicesCommand());
27 addCommand(new ListGroupsCommand());
28 addCommand(new ListIdentitiesCommand());
29 addCommand(new ListStickerPacksCommand());
30 addCommand(new QuitGroupCommand());
31 addCommand(new ReceiveCommand());
32 addCommand(new RegisterCommand());
33 addCommand(new RemoveContactCommand());
34 addCommand(new RemoveDeviceCommand());
35 addCommand(new RemovePinCommand());
36 addCommand(new RemoteDeleteCommand());
37 addCommand(new SendCommand());
38 addCommand(new SendContactsCommand());
39 addCommand(new SendPaymentNotificationCommand());
40 addCommand(new SendReactionCommand());
41 addCommand(new SendReceiptCommand());
42 addCommand(new SendSyncRequestCommand());
43 addCommand(new SendTypingCommand());
44 addCommand(new SetPinCommand());
45 addCommand(new SubmitRateLimitChallengeCommand());
46 addCommand(new StartLinkCommand());
47 addCommand(new TrustCommand());
48 addCommand(new UnblockCommand());
49 addCommand(new UnregisterCommand());
50 addCommand(new UpdateAccountCommand());
51 addCommand(new UpdateConfigurationCommand());
52 addCommand(new UpdateContactCommand());
53 addCommand(new UpdateGroupCommand());
54 addCommand(new UpdateProfileCommand());
55 addCommand(new UploadStickerPackCommand());
56 addCommand(new VerifyCommand());
57 addCommand(new VersionCommand());
58 }
59
60 public static Map<String, SubparserAttacher> getCommandSubparserAttachers() {
61 return commandSubparserAttacher;
62 }
63
64 public static Command getCommand(String commandKey) {
65 if (!commands.containsKey(commandKey)) {
66 return null;
67 }
68 return commands.get(commandKey);
69 }
70
71 private static void addCommand(Command command) {
72 commands.put(command.getName(), command);
73 if (command instanceof CliCommand) {
74 commandSubparserAttacher.put(command.getName(), ((CliCommand) command)::attachToSubparser);
75 }
76 }
77 }