wkd-java/wkd-java-cli/src/main/java/pgp/wkd/cli/WKDCLI.java

44 lines
1.3 KiB
Java
Raw Normal View History

2022-02-21 11:51:30 +01:00
// SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package pgp.wkd.cli;
2022-02-21 14:16:55 +01:00
import pgp.wkd.cli.command.Fetch;
import picocli.CommandLine;
@CommandLine.Command(
subcommands = {
CommandLine.HelpCommand.class,
Fetch.class
}
)
2022-02-21 11:51:30 +01:00
public class WKDCLI {
2022-02-21 14:16:55 +01:00
public static void main(String[] args) {
int exitCode = execute(args);
if (exitCode != 0) {
System.exit(exitCode);
}
}
public static int execute(String[] args) {
return new CommandLine(WKDCLI.class)
.setExitCodeExceptionMapper(new CommandLine.IExitCodeExceptionMapper() {
@Override
public int getExitCode(Throwable exception) {
if (exception instanceof MissingUserIdException) {
return MissingUserIdException.ERROR_CODE;
} else if (exception instanceof CertNotFetchableException) {
return CertNotFetchableException.ERROR_CODE;
}
// Others get mapped to 1
return 1;
}
})
2022-02-21 14:16:55 +01:00
.setCommandName("wkdcli")
.execute(args);
}
2022-02-21 11:51:30 +01:00
}