]> nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/signal/commands/Commands.java
Refactor dbus client mode to improve maintainability
[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 UpdateContactCommand());
43 addCommand(new UpdateGroupCommand());
44 addCommand(new UpdateProfileCommand());
45 addCommand(new UploadStickerPackCommand());
46 addCommand(new VerifyCommand());
47 addCommand(new VersionCommand());
48 }
49
50 public static Map<String, SubparserAttacher> getCommandSubparserAttachers() {
51 return commandSubparserAttacher;
52 }
53
54 public static Command getCommand(String commandKey) {
55 if (!commands.containsKey(commandKey)) {
56 return null;
57 }
58 return commands.get(commandKey);
59 }
60
61 private static void addCommand(Command command) {
62 commands.put(command.getName(), command);
63 if (command instanceof CliCommand) {
64 commandSubparserAttacher.put(command.getName(), ((CliCommand) command)::attachToSubparser);
65 }
66 }
67 }