2022-01-11 13:46:05 +01:00
|
|
|
// SPDX-FileCopyrightText: 2021 Paul Schaub <vanitasvitae@fsfe.org>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
package sop.cli.picocli.commands;
|
|
|
|
|
|
|
|
import picocli.CommandLine;
|
|
|
|
import sop.cli.picocli.Print;
|
|
|
|
import sop.cli.picocli.SopCLI;
|
|
|
|
import sop.operation.Version;
|
|
|
|
|
2022-08-04 12:15:53 +02:00
|
|
|
@CommandLine.Command(name = "version", resourceBundle = "msg_version",
|
2022-01-11 13:46:05 +01:00
|
|
|
exitCodeOnInvalidInput = 37)
|
2022-05-29 21:17:03 +02:00
|
|
|
public class VersionCmd extends AbstractSopCmd {
|
2022-01-11 13:46:05 +01:00
|
|
|
|
|
|
|
@CommandLine.ArgGroup()
|
|
|
|
Exclusive exclusive;
|
|
|
|
|
|
|
|
static class Exclusive {
|
2022-08-04 12:15:53 +02:00
|
|
|
@CommandLine.Option(names = "--extended")
|
2022-01-11 13:46:05 +01:00
|
|
|
boolean extended;
|
|
|
|
|
2022-08-04 12:15:53 +02:00
|
|
|
@CommandLine.Option(names = "--backend")
|
2022-01-11 13:46:05 +01:00
|
|
|
boolean backend;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run() {
|
2022-05-29 21:17:03 +02:00
|
|
|
Version version = throwIfUnsupportedSubcommand(
|
|
|
|
SopCLI.getSop().version(), "version");
|
2022-01-11 13:46:05 +01:00
|
|
|
|
|
|
|
if (exclusive == null) {
|
|
|
|
Print.outln(version.getName() + " " + version.getVersion());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (exclusive.extended) {
|
|
|
|
Print.outln(version.getExtendedVersion());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (exclusive.backend) {
|
|
|
|
Print.outln(version.getBackendVersion());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|