mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-12-16 09:11:08 +01:00
Wip
This commit is contained in:
parent
3ba57109a1
commit
ddcd4bff00
17 changed files with 478 additions and 189 deletions
|
|
@ -4,12 +4,11 @@
|
|||
|
||||
package pgp.cert_d.cli;
|
||||
|
||||
import org.pgpainless.certificate_store.CertificateCertificateReader;
|
||||
import org.pgpainless.certificate_store.CertificateReader;
|
||||
import org.pgpainless.certificate_store.SharedPGPCertificateDirectoryAdapter;
|
||||
import pgp.cert_d.SharedPGPCertificateDirectoryImpl;
|
||||
import pgp.cert_d.cli.commands.Get;
|
||||
import pgp.cert_d.cli.commands.Insert;
|
||||
import pgp.cert_d.cli.commands.PrintDirectory;
|
||||
import pgp.cert_d.cli.commands.Import;
|
||||
import pgp.cert_d.exception.NotAStoreException;
|
||||
import pgp.certificate_store.CertificateStore;
|
||||
import picocli.CommandLine;
|
||||
|
|
@ -18,8 +17,7 @@ import java.io.File;
|
|||
|
||||
@CommandLine.Command(
|
||||
subcommands = {
|
||||
Insert.class,
|
||||
PrintDirectory.class,
|
||||
Import.class,
|
||||
Get.class,
|
||||
}
|
||||
)
|
||||
|
|
@ -29,7 +27,6 @@ public class PGPCertDCli {
|
|||
File baseDirectory;
|
||||
|
||||
private static CertificateStore certificateStore;
|
||||
private static String baseDir;
|
||||
|
||||
private int executionStrategy(CommandLine.ParseResult parseResult) {
|
||||
try {
|
||||
|
|
@ -45,12 +42,11 @@ public class PGPCertDCli {
|
|||
if (baseDirectory != null) {
|
||||
certificateDirectory = new SharedPGPCertificateDirectoryImpl(
|
||||
baseDirectory,
|
||||
new CertificateCertificateReader());
|
||||
new CertificateReader());
|
||||
} else {
|
||||
certificateDirectory = new SharedPGPCertificateDirectoryImpl(
|
||||
new CertificateCertificateReader());
|
||||
new CertificateReader());
|
||||
}
|
||||
baseDir = certificateDirectory.getBaseDirectory().getAbsolutePath();
|
||||
certificateStore = new SharedPGPCertificateDirectoryAdapter(certificateDirectory);
|
||||
}
|
||||
|
||||
|
|
@ -64,8 +60,4 @@ public class PGPCertDCli {
|
|||
public static CertificateStore getCertificateDirectory() {
|
||||
return certificateStore;
|
||||
}
|
||||
|
||||
public static String getBaseDir() {
|
||||
return baseDir;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ import pgp.certificate_store.Certificate;
|
|||
import pgp.certificate_store.MergeCallback;
|
||||
import picocli.CommandLine;
|
||||
|
||||
@CommandLine.Command(name = "insert",
|
||||
description = "Insert or update a certificate")
|
||||
public class Insert implements Runnable {
|
||||
@CommandLine.Command(name = "import",
|
||||
description = "Import or update a certificate")
|
||||
public class Import implements Runnable {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Insert.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Import.class);
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
// 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 picocli.CommandLine;
|
||||
|
||||
@CommandLine.Command(
|
||||
name = "print-directory",
|
||||
description = "Print the location of the certificate directory"
|
||||
)
|
||||
public class PrintDirectory implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// CHECKSTYLE:OFF
|
||||
System.out.println(PGPCertDCli.getBaseDir());
|
||||
// CHECKSTYLE:ON
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue