2021-10-07 15:48:52 +02:00
|
|
|
// SPDX-FileCopyrightText: 2021 Paul Schaub <vanitasvitae@fsfe.org>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2021-07-15 16:55:13 +02:00
|
|
|
package org.pgpainless.cli;
|
|
|
|
|
|
|
|
import org.pgpainless.sop.SOPImpl;
|
|
|
|
import sop.cli.picocli.SopCLI;
|
|
|
|
|
2022-04-02 17:16:37 +02:00
|
|
|
/**
|
|
|
|
* This class merely binds PGPainless to {@link SopCLI} by injecting a {@link SOPImpl} instance.
|
|
|
|
* CLI command calls are then simply forwarded to {@link SopCLI#execute(String[])}.
|
|
|
|
*/
|
2021-07-15 16:55:13 +02:00
|
|
|
public class PGPainlessCLI {
|
|
|
|
|
|
|
|
static {
|
2022-08-04 14:05:12 +02:00
|
|
|
SopCLI.EXECUTABLE_NAME = "pgpainless-cli";
|
2021-07-15 16:55:13 +02:00
|
|
|
SopCLI.setSopInstance(new SOPImpl());
|
|
|
|
}
|
|
|
|
|
2023-01-16 19:38:52 +01:00
|
|
|
/**
|
|
|
|
* Main method of the CLI application.
|
|
|
|
* @param args arguments
|
|
|
|
*/
|
2021-07-15 16:55:13 +02:00
|
|
|
public static void main(String[] args) {
|
|
|
|
int result = execute(args);
|
|
|
|
if (result != 0) {
|
|
|
|
System.exit(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-16 19:38:52 +01:00
|
|
|
/**
|
|
|
|
* Execute the given command and return the exit code of the program.
|
|
|
|
*
|
|
|
|
* @param args command string array (e.g. ["pgpainless-cli", "generate-key", "Alice"])
|
|
|
|
* @return exit code
|
|
|
|
*/
|
2021-07-15 16:55:13 +02:00
|
|
|
public static int execute(String... args) {
|
|
|
|
return SopCLI.execute(args);
|
|
|
|
}
|
|
|
|
}
|