mirror of
https://codeberg.org/PGPainless/pgpeasy.git
synced 2024-12-04 21:32:07 +01:00
Reuse other CLI components in PGPeasy
This commit is contained in:
parent
a0c2fc468a
commit
76dde5c91f
14 changed files with 76 additions and 203 deletions
18
build.gradle
18
build.gradle
|
@ -5,19 +5,27 @@ plugins {
|
|||
group 'org.pgpainless'
|
||||
version '0.1.0-SNAPSHOT'
|
||||
|
||||
apply from: 'version.gradle'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
|
||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
|
||||
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
|
||||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
|
||||
|
||||
// CLI
|
||||
implementation 'info.picocli:picocli:4.6.3'
|
||||
implementation "info.picocli:picocli:$picocliVersion"
|
||||
|
||||
// PGPainless
|
||||
implementation "org.pgpainless:pgpainless-core:1.1.2"
|
||||
implementation "org.pgpainless:pgpainless-cli:$pgpainlessVersion"
|
||||
implementation "org.pgpainless:sop-java-picocli:$sopJavaVersion"
|
||||
implementation ("org.pgpainless:wkd-java-cli:$wkdVersion") {
|
||||
exclude group:'rg.slf4j', module:'slf4j-nop'
|
||||
}
|
||||
implementation "org.pgpainless:vks-java-cli:$vksVersion"
|
||||
implementation "org.pgpainless:pgpainless-cert-d-cli:$certDPgpainlessVersion"
|
||||
}
|
||||
|
||||
application {
|
||||
|
|
|
@ -1,28 +1,55 @@
|
|||
package org.pgpainless.pgpeasy;
|
||||
|
||||
import org.pgpainless.pgpeasy.commands.Cert;
|
||||
import org.pgpainless.pgpeasy.commands.Decrypt;
|
||||
import org.pgpainless.pgpeasy.commands.Encrypt;
|
||||
import org.pgpainless.pgpeasy.commands.Key;
|
||||
import org.pgpainless.cli.PGPainlessCLI;
|
||||
import org.pgpainless.pgpeasy.commands.Packet;
|
||||
import org.pgpainless.pgpeasy.commands.Sign;
|
||||
import org.pgpainless.pgpeasy.commands.Verify;
|
||||
import org.pgpainless.pgpeasy.commands.WKD;
|
||||
import org.pgpainless.pgpeasy.commands.WOT;
|
||||
import org.pgpainless.sop.SOPImpl;
|
||||
import pgp.cert_d.cli.PGPCertDCli;
|
||||
import pgp.vks.client.cli.VKSCLI;
|
||||
import pgp.wkd.cli.WKDCLI;
|
||||
import picocli.AutoComplete;
|
||||
import picocli.CommandLine;
|
||||
import sop.cli.picocli.SopCLI;
|
||||
import sop.cli.picocli.commands.ArmorCmd;
|
||||
import sop.cli.picocli.commands.DearmorCmd;
|
||||
import sop.cli.picocli.commands.DecryptCmd;
|
||||
import sop.cli.picocli.commands.DetachInbandSignatureAndMessageCmd;
|
||||
import sop.cli.picocli.commands.EncryptCmd;
|
||||
import sop.cli.picocli.commands.ExtractCertCmd;
|
||||
import sop.cli.picocli.commands.GenerateKeyCmd;
|
||||
import sop.cli.picocli.commands.SignCmd;
|
||||
import sop.cli.picocli.commands.VerifyCmd;
|
||||
|
||||
@CommandLine.Command(
|
||||
subcommands = {
|
||||
Encrypt.class,
|
||||
Decrypt.class,
|
||||
Sign.class,
|
||||
Verify.class,
|
||||
Key.class,
|
||||
Cert.class,
|
||||
Packet.class,
|
||||
WKD.class,
|
||||
// Inherit from SOP
|
||||
EncryptCmd.class,
|
||||
DecryptCmd.class,
|
||||
SignCmd.class,
|
||||
VerifyCmd.class,
|
||||
ArmorCmd.class,
|
||||
DearmorCmd.class,
|
||||
ExtractCertCmd.class,
|
||||
GenerateKeyCmd.class,
|
||||
DetachInbandSignatureAndMessageCmd.class,
|
||||
|
||||
// SOP as subcommand
|
||||
SopCLI.class,
|
||||
|
||||
// WKD
|
||||
WKDCLI.class,
|
||||
|
||||
// VKS
|
||||
VKSCLI.class,
|
||||
|
||||
// PGP-Cert-D
|
||||
PGPCertDCli.class,
|
||||
|
||||
// PGPeasy
|
||||
WOT.class,
|
||||
Packet.class,
|
||||
|
||||
// Picocli
|
||||
CommandLine.HelpCommand.class,
|
||||
AutoComplete.GenerateCompletion.class
|
||||
}
|
||||
|
@ -30,6 +57,7 @@ import picocli.CommandLine;
|
|||
public class PGPeasy {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SopCLI.setSopInstance(new SOPImpl());
|
||||
int exitCode = execute(args);
|
||||
if (exitCode != 0) {
|
||||
System.exit(exitCode);
|
||||
|
@ -37,10 +65,13 @@ public class PGPeasy {
|
|||
}
|
||||
|
||||
public static int execute(String[] args) {
|
||||
return new CommandLine(PGPeasy.class)
|
||||
CommandLine cmd = new CommandLine(PGPeasy.class);
|
||||
// Hide generate-completion command
|
||||
CommandLine gen = cmd.getSubcommands().get("generate-completion");
|
||||
gen.getCommandSpec().usageMessage().hidden(true);
|
||||
|
||||
return cmd
|
||||
.setCommandName("pgpeasy")
|
||||
// .setExecutionExceptionHandler(new SOPExecutionExceptionHandler())
|
||||
// .setExitCodeExceptionMapper(new SOPExceptionExitCodeMapper())
|
||||
.setCaseInsensitiveEnumValuesAllowed(true)
|
||||
.execute(args);
|
||||
}
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
package org.pgpainless.pgpeasy.commands;
|
||||
|
||||
import org.pgpainless.pgpeasy.commands.cert.Certify;
|
||||
import org.pgpainless.pgpeasy.commands.key.ExtractCert;
|
||||
import picocli.CommandLine;
|
||||
|
||||
@CommandLine.Command(
|
||||
name = "cert",
|
||||
description = "Execute operations related to OpenPGP certificates",
|
||||
subcommands = {
|
||||
ExtractCert.class,
|
||||
Certify.class
|
||||
}
|
||||
)
|
||||
public class Cert implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package org.pgpainless.pgpeasy.commands;
|
||||
|
||||
import picocli.CommandLine;
|
||||
|
||||
@CommandLine.Command(
|
||||
name = "decrypt",
|
||||
description = "Decrypt a message"
|
||||
)
|
||||
public class Decrypt implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
package org.pgpainless.pgpeasy.commands;
|
||||
|
||||
import picocli.CommandLine;
|
||||
|
||||
@CommandLine.Command(
|
||||
name = "encrypt",
|
||||
description = "Encrypt a message"
|
||||
)
|
||||
public class Encrypt implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("Not yet implemented.");
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package org.pgpainless.pgpeasy.commands;
|
||||
|
||||
import org.pgpainless.pgpeasy.commands.key.ExtractCert;
|
||||
import org.pgpainless.pgpeasy.commands.key.Generate;
|
||||
import picocli.CommandLine;
|
||||
|
||||
@CommandLine.Command(
|
||||
name = "key",
|
||||
description = "Operations related to secret keys",
|
||||
subcommands = {
|
||||
ExtractCert.class,
|
||||
Generate.class,
|
||||
}
|
||||
)
|
||||
public class Key implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package org.pgpainless.pgpeasy.commands;
|
||||
|
||||
import picocli.CommandLine;
|
||||
|
||||
@CommandLine.Command(
|
||||
name = "sign",
|
||||
description = "Sign a message"
|
||||
)
|
||||
public class Sign implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package org.pgpainless.pgpeasy.commands;
|
||||
|
||||
import picocli.CommandLine;
|
||||
|
||||
@CommandLine.Command(
|
||||
name = "verify",
|
||||
description = "Verify a signed message."
|
||||
)
|
||||
public class Verify implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package org.pgpainless.pgpeasy.commands;
|
||||
|
||||
import org.pgpainless.pgpeasy.commands.wkd.Fetch;
|
||||
import picocli.CommandLine;
|
||||
|
||||
@CommandLine.Command(
|
||||
name = "wkd",
|
||||
description = "Interact with the Web Key Directory",
|
||||
subcommands = {
|
||||
Fetch.class,
|
||||
}
|
||||
)
|
||||
public class WKD implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package org.pgpainless.pgpeasy.commands.cert;
|
||||
|
||||
import picocli.CommandLine;
|
||||
|
||||
@CommandLine.Command(
|
||||
name = "certify",
|
||||
description = "Create a signature on a certificate."
|
||||
)
|
||||
public class Certify implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package org.pgpainless.pgpeasy.commands.key;
|
||||
|
||||
import picocli.CommandLine;
|
||||
|
||||
@CommandLine.Command(
|
||||
name = "extract",
|
||||
description = "Extract a certificate from a secret key"
|
||||
)
|
||||
public class ExtractCert implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package org.pgpainless.pgpeasy.commands.key;
|
||||
|
||||
import picocli.CommandLine;
|
||||
|
||||
@CommandLine.Command(
|
||||
name = "generate",
|
||||
description = "Generate a new OpenPGP key"
|
||||
)
|
||||
public class Generate implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package org.pgpainless.pgpeasy.commands.wkd;
|
||||
|
||||
import picocli.CommandLine;
|
||||
|
||||
@CommandLine.Command(
|
||||
name = "fetch",
|
||||
description = "Fetch a certificate from the Web Key Directory"
|
||||
)
|
||||
public class Fetch implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
14
version.gradle
Normal file
14
version.gradle
Normal file
|
@ -0,0 +1,14 @@
|
|||
allprojects {
|
||||
ext {
|
||||
bouncyCastleVersion = '1.71'
|
||||
slf4jVersion = '1.7.36'
|
||||
logbackVersion = '1.2.11'
|
||||
junitVersion = '5.8.2'
|
||||
sopJavaVersion = '1.2.3'
|
||||
picocliVersion = '4.6.3'
|
||||
pgpainlessVersion = '1.2.1'
|
||||
wkdVersion = '0.1.1'
|
||||
vksVersion = '0.1.2'
|
||||
certDPgpainlessVersion = '0.1.2'
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue