mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-30 11:00:38 +00:00
Add JsonRpcMultiCommand
This commit is contained in:
parent
64af4914ee
commit
9c67aabebb
8 changed files with 90 additions and 26 deletions
|
@ -0,0 +1,30 @@
|
|||
package org.asamk.signal.commands;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import net.sourceforge.argparse4j.inf.Namespace;
|
||||
|
||||
import org.asamk.signal.JsonWriter;
|
||||
import org.asamk.signal.OutputType;
|
||||
import org.asamk.signal.commands.exceptions.CommandException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface JsonRpcMultiLocalCommand extends JsonRpcMultiCommand<Map<String, Object>>, MultiLocalCommand {
|
||||
|
||||
default TypeReference<Map<String, Object>> getRequestType() {
|
||||
return new TypeReference<>() {};
|
||||
}
|
||||
|
||||
default void handleCommand(
|
||||
Map<String, Object> request, SignalCreator c, JsonWriter jsonWriter
|
||||
) throws CommandException {
|
||||
Namespace commandNamespace = new JsonRpcNamespace(request == null ? Map.of() : request);
|
||||
handleCommand(commandNamespace, c, jsonWriter);
|
||||
}
|
||||
|
||||
default List<OutputType> getSupportedOutputTypes() {
|
||||
return List.of(OutputType.PLAIN_TEXT, OutputType.JSON);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue