Add sticker pack url to list output

This commit is contained in:
AsamK 2022-01-03 18:50:27 +01:00
parent 99eef05084
commit 8a5f98dac6
10 changed files with 133 additions and 44 deletions

View file

@ -35,21 +35,29 @@ public class ListStickerPacksCommand implements JsonRpcLocalCommand {
jsonWriter.write(jsonStickerPacks);
} else if (outputWriter instanceof PlainTextWriter plainTextWriter) {
for (final var sticker : stickerPacks) {
plainTextWriter.println("Pack {}: “{}” by “{}” has {} stickers",
plainTextWriter.println("Pack {}: “{}” by “{}” has {} stickers. {}",
Hex.toStringCondensed(sticker.packId().serialize()),
sticker.title(),
sticker.author(),
sticker.stickers().size());
sticker.stickers().size(),
sticker.url().getUrl());
}
}
}
private record JsonStickerPack(
String packId, boolean installed, String title, String author, JsonSticker cover, List<JsonSticker> stickers
String packId,
String url,
boolean installed,
String title,
String author,
JsonSticker cover,
List<JsonSticker> stickers
) {
JsonStickerPack(StickerPack stickerPack) {
this(Hex.toStringCondensed(stickerPack.packId().serialize()),
stickerPack.url().getUrl().toString(),
stickerPack.installed(),
stickerPack.title(),
stickerPack.author(),

View file

@ -43,10 +43,10 @@ public class UploadStickerPackCommand implements JsonRpcLocalCommand {
try {
var url = m.uploadStickerPack(path);
if (outputWriter instanceof PlainTextWriter writer) {
writer.println("{}", url);
writer.println("{}", url.getUrl());
} else {
final var writer = (JsonWriter) outputWriter;
writer.write(Map.of("url", url));
writer.write(Map.of("url", url.getUrl()));
}
} catch (IOException e) {
throw new IOErrorException("Upload error (maybe image size too large):" + e.getMessage(), e);