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