signal-cli/src/main/java/org/asamk/signal/commands/Commands.java
2021-08-22 14:25:48 +02:00

66 lines
2.4 KiB
Java

package org.asamk.signal.commands;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
public class Commands {
private static final Map<String, Command> commands = new HashMap<>();
private static final Map<String, SubparserAttacher> commandSubparserAttacher = new TreeMap<>();
static {
addCommand(new AddDeviceCommand());
addCommand(new BlockCommand());
addCommand(new DaemonCommand());
addCommand(new GetUserStatusCommand());
addCommand(new JoinGroupCommand());
addCommand(new JsonRpcDispatcherCommand());
addCommand(new LinkCommand());
addCommand(new ListContactsCommand());
addCommand(new ListDevicesCommand());
addCommand(new ListGroupsCommand());
addCommand(new ListIdentitiesCommand());
addCommand(new QuitGroupCommand());
addCommand(new ReceiveCommand());
addCommand(new RegisterCommand());
addCommand(new RemoveDeviceCommand());
addCommand(new RemoteDeleteCommand());
addCommand(new RemovePinCommand());
addCommand(new SendCommand());
addCommand(new SendContactsCommand());
addCommand(new SendReactionCommand());
addCommand(new SendReceiptCommand());
addCommand(new SendSyncRequestCommand());
addCommand(new SendTypingCommand());
addCommand(new SetPinCommand());
addCommand(new TrustCommand());
addCommand(new UnblockCommand());
addCommand(new UnregisterCommand());
addCommand(new UpdateAccountCommand());
addCommand(new UpdateContactCommand());
addCommand(new UpdateGroupCommand());
addCommand(new UpdateProfileCommand());
addCommand(new UploadStickerPackCommand());
addCommand(new VerifyCommand());
addCommand(new VersionCommand());
}
public static Map<String, SubparserAttacher> getCommandSubparserAttachers() {
return commandSubparserAttacher;
}
public static Command getCommand(String commandKey) {
if (!commands.containsKey(commandKey)) {
return null;
}
return commands.get(commandKey);
}
private static void addCommand(Command command) {
commands.put(command.getName(), command);
if (command instanceof CliCommand) {
commandSubparserAttacher.put(command.getName(), ((CliCommand) command)::attachToSubparser);
}
}
}