Implement very basic list command

This commit is contained in:
Paul Schaub 2022-08-08 15:04:34 +02:00
parent 6a16d0cff5
commit 3267a330bf
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
4 changed files with 54 additions and 1 deletions

View file

@ -12,6 +12,7 @@ import pgp.cert_d.cli.commands.Export;
import pgp.cert_d.cli.commands.Get; import pgp.cert_d.cli.commands.Get;
import pgp.cert_d.cli.commands.Insert; import pgp.cert_d.cli.commands.Insert;
import pgp.cert_d.cli.commands.Import; import pgp.cert_d.cli.commands.Import;
import pgp.cert_d.cli.commands.List;
import pgp.cert_d.cli.commands.Setup; import pgp.cert_d.cli.commands.Setup;
import pgp.cert_d.jdbc.sqlite.DatabaseSubkeyLookup; import pgp.cert_d.jdbc.sqlite.DatabaseSubkeyLookup;
import pgp.cert_d.jdbc.sqlite.SqliteSubkeyLookupDaoImpl; import pgp.cert_d.jdbc.sqlite.SqliteSubkeyLookupDaoImpl;
@ -32,7 +33,8 @@ import java.sql.SQLException;
Insert.class, Insert.class,
Import.class, Import.class,
Get.class, Get.class,
Setup.class Setup.class,
List.class
} }
) )
public class PGPCertDCli { public class PGPCertDCli {

View file

@ -0,0 +1,29 @@
// SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package pgp.cert_d.cli.commands;
import pgp.cert_d.cli.PGPCertDCli;
import pgp.certificate_store.Certificate;
import picocli.CommandLine;
import java.util.Iterator;
@CommandLine.Command(name = "list",
resourceBundle = "msg_list"
)
public class List implements Runnable {
@Override
public void run() {
Iterator<Certificate> certificates = PGPCertDCli.getCertificateDirectory()
.getCertificates();
while (certificates.hasNext()) {
Certificate certificate = certificates.next();
// CHECKSTYLE:OFF
System.out.println(certificate.getFingerprint());
// CHECKSTYLE:ON
}
}
}

View file

@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
#
# SPDX-License-Identifier: Apache-2.0
usage.header=List all certificates in the directory
store=Overwrite the default certificate directory path
# Generic TODO: Remove when bumping picocli to 4.7.0
usage.synopsisHeading=Usage:\u0020
usage.commandListHeading = %nCommands:%n
usage.optionListHeading = %nOptions:%n
usage.footerHeading=Powered by picocli%n

View file

@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
#
# SPDX-License-Identifier: Apache-2.0
usage.header=Liste alle Zertifikate im Verzeichnis auf
store=Überschreibe den Standardpfad des Zertifikatsverzeichnisses
# Generic TODO: Remove when bumping picocli to 4.7.0
usage.synopsisHeading=Aufruf:\u0020
usage.commandListHeading=%nBefehle:%n
usage.optionListHeading = %nOptionen:%n
usage.footerHeading=Powered by Picocli%n