// SPDX-FileCopyrightText: 2021 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
packagesop.cli.picocli.commands;
importjava.io.File;
importjava.io.FileInputStream;
importjava.io.FileNotFoundException;
importjava.io.FileOutputStream;
importjava.io.IOException;
importjava.util.ArrayList;
importjava.util.List;
importpicocli.CommandLine;
importsop.MicAlg;
importsop.ReadyWithResult;
importsop.SigningResult;
importsop.cli.picocli.Print;
importsop.cli.picocli.SopCLI;
importsop.enums.SignAs;
importsop.exception.SOPGPException;
importsop.operation.Sign;
@CommandLine.Command(name="sign",
description="Create a detached signature on the data from standard input",
exitCodeOnInvalidInput=37)
publicclassSignCmdimplementsRunnable{
@CommandLine.Option(names="--no-armor",
description="ASCII armor the output",
negatable=true)
booleanarmor=true;
@CommandLine.Option(names="--as",description="Defaults to 'binary'. If '--as=text' and the input data is not valid UTF-8, sign fails with return code 53.",
paramLabel="{binary|text}")
SignAstype;
@CommandLine.Parameters(description="Secret keys used for signing",
@CommandLine.Option(names="--micalg-out",description="Emits the digest algorithm used to the specified file in a way that can be used to populate the micalg parameter for the PGP/MIME Content-Type (RFC3156)",
paramLabel="MICALG")
FilemicAlgOut;
@Override
publicvoidrun(){
Signsign=SopCLI.getSop().sign();
if(sign==null){
thrownewSOPGPException.UnsupportedSubcommand("Command 'sign' not implemented.");