mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-30 02:50:39 +00:00
Add JsonRpcMultiCommand
This commit is contained in:
parent
64af4914ee
commit
9c67aabebb
8 changed files with 90 additions and 26 deletions
|
@ -2,13 +2,12 @@ package org.asamk.signal.commands;
|
|||
|
||||
import org.asamk.signal.BaseConfig;
|
||||
import org.asamk.signal.JsonWriter;
|
||||
import org.asamk.signal.OutputWriter;
|
||||
import org.asamk.signal.commands.exceptions.CommandException;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class VersionCommand implements JsonRpcSingleCommand<Void> {
|
||||
public class VersionCommand implements JsonRpcSingleCommand<Void>, JsonRpcMultiCommand<Void> {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -17,9 +16,19 @@ public class VersionCommand implements JsonRpcSingleCommand<Void> {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Void request, final Manager m, final OutputWriter outputWriter
|
||||
final Void request, final Manager m, final JsonWriter jsonWriter
|
||||
) throws CommandException {
|
||||
final var jsonWriter = (JsonWriter) outputWriter;
|
||||
outputVersion(jsonWriter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Void request, final SignalCreator c, final JsonWriter jsonWriter
|
||||
) throws CommandException {
|
||||
outputVersion(jsonWriter);
|
||||
}
|
||||
|
||||
private void outputVersion(final JsonWriter jsonWriter) {
|
||||
jsonWriter.write(Map.of("version", BaseConfig.PROJECT_VERSION));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue