1 package org
.asamk
.signal
.commands
;
3 import net
.sourceforge
.argparse4j
.inf
.Namespace
;
4 import net
.sourceforge
.argparse4j
.inf
.Subparser
;
6 import org
.asamk
.signal
.PlainTextWriterImpl
;
7 import org
.asamk
.signal
.commands
.exceptions
.CommandException
;
8 import org
.asamk
.signal
.commands
.exceptions
.IOErrorException
;
9 import org
.asamk
.signal
.commands
.exceptions
.UserErrorException
;
10 import org
.asamk
.signal
.manager
.Manager
;
11 import org
.asamk
.signal
.manager
.StickerPackInvalidException
;
12 import org
.slf4j
.Logger
;
13 import org
.slf4j
.LoggerFactory
;
16 import java
.io
.IOException
;
18 public class UploadStickerPackCommand
implements LocalCommand
{
20 private final static Logger logger
= LoggerFactory
.getLogger(UploadStickerPackCommand
.class);
23 public void attachToSubparser(final Subparser subparser
) {
24 subparser
.help("Upload a new sticker pack, consisting of a manifest file and the stickers images.");
25 subparser
.addArgument("path")
26 .help("The path of the manifest.json or a zip file containing the sticker pack you wish to upload.");
30 public void handleCommand(final Namespace ns
, final Manager m
) throws CommandException
{
31 final var writer
= new PlainTextWriterImpl(System
.out
);
32 var path
= new File(ns
.getString("path"));
35 var url
= m
.uploadStickerPack(path
);
36 writer
.println("{}", url
);
37 } catch (IOException e
) {
38 throw new IOErrorException("Upload error: " + e
.getMessage());
39 } catch (StickerPackInvalidException e
) {
40 throw new UserErrorException("Invalid sticker pack: " + e
.getMessage());