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