mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2025-09-09 10:19:47 +02:00
Implement profiles
This commit is contained in:
parent
b8544396f8
commit
5935d65c90
11 changed files with 75 additions and 43 deletions
|
@ -31,7 +31,7 @@ public class GenerateKeyCmd extends AbstractSopCmd {
|
|||
String withKeyPassword;
|
||||
|
||||
@CommandLine.Option(names = "--profile",
|
||||
paramLabel = "PROFILE")
|
||||
paramLabel = "PROFILE")
|
||||
String profile = "default";
|
||||
|
||||
@Override
|
||||
|
@ -47,7 +47,12 @@ public class GenerateKeyCmd extends AbstractSopCmd {
|
|||
generateKey.noArmor();
|
||||
}
|
||||
|
||||
generateKey.profile(profile);
|
||||
try {
|
||||
generateKey.profile(profile);
|
||||
} catch (SOPGPException.UnsupportedProfile e) {
|
||||
String errorMsg = getMsg("sop.error.usage.profile_not_supported", "generate-key", profile);
|
||||
throw new SOPGPException.UnsupportedProfile(errorMsg, e);
|
||||
}
|
||||
|
||||
if (withKeyPassword != null) {
|
||||
try {
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
package sop.cli.picocli.commands;
|
||||
|
||||
import picocli.CommandLine;
|
||||
import sop.Profile;
|
||||
import sop.cli.picocli.SopCLI;
|
||||
import sop.exception.SOPGPException;
|
||||
import sop.operation.ListProfiles;
|
||||
|
||||
@CommandLine.Command(name = "list-profiles",
|
||||
|
@ -13,7 +15,7 @@ import sop.operation.ListProfiles;
|
|||
exitCodeOnInvalidInput = 37)
|
||||
public class ListProfilesCmd extends AbstractSopCmd {
|
||||
|
||||
@CommandLine.Parameters(paramLabel = "COMMAND", arity="0..1", descriptionKey = "subcommand")
|
||||
@CommandLine.Parameters(paramLabel = "COMMAND", arity="1", descriptionKey = "subcommand")
|
||||
String subcommand;
|
||||
|
||||
@Override
|
||||
|
@ -21,19 +23,15 @@ public class ListProfilesCmd extends AbstractSopCmd {
|
|||
ListProfiles listProfiles = throwIfUnsupportedSubcommand(
|
||||
SopCLI.getSop().listProfiles(), "list-profiles");
|
||||
|
||||
if (subcommand == null) {
|
||||
for (String profile : listProfiles.global()) {
|
||||
try {
|
||||
for (Profile profile : listProfiles.subcommand(subcommand)) {
|
||||
// CHECKSTYLE:OFF
|
||||
System.out.println(profile);
|
||||
// CHECKSTYLE:ON
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for (String profile : listProfiles.ofCommand(subcommand)) {
|
||||
// CHECKSTYLE:OFF
|
||||
System.out.println(profile);
|
||||
// CHECKSTYLE:ON
|
||||
} catch (SOPGPException.UnsupportedProfile e) {
|
||||
String errorMsg = getMsg("sop.error.feature_support.subcommand_does_not_support_profiles", subcommand);
|
||||
throw new SOPGPException.UnsupportedProfile(errorMsg, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
usage.header=Generate a secret key
|
||||
no-armor=ASCII armor the output
|
||||
USERID[0..*]=User-ID, e.g. "Alice <alice@example.com>"
|
||||
profile=Profile identifier to switch between profiles
|
||||
with-key-password.0=Password to protect the private key with
|
||||
with-key-password.1=Is an INDIRECT data type (e.g. file, environment variable, file descriptor...).
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
usage.header=Generiere einen privaten Schlüssel
|
||||
no-armor=Schütze Ausgabe mit ASCII Armor
|
||||
USERID[0..*]=Nutzer-ID, z.B.. "Alice <alice@example.com>"
|
||||
profile=Profil-Identifikator um zwischen Profilen zu wechseln
|
||||
with-key-password.0=Passwort zum Schutz des privaten Schlüssels
|
||||
with-key-password.1=Ist ein INDIREKTER Datentyp (z.B.. Datei, Umgebungsvariable, Dateideskriptor...).
|
||||
|
||||
|
|
|
@ -74,8 +74,10 @@ sop.error.runtime.cannot_decrypt_message=Message could not be decrypted.
|
|||
sop.error.usage.password_or_cert_required=At least one password file or cert file required for encryption.
|
||||
sop.error.usage.argument_required=Argument '%s' is required.
|
||||
sop.error.usage.parameter_required=Parameter '%s' is required.
|
||||
sop.error.usage.profile_not_supported=Subcommand '%s' does not support profile '%s'.
|
||||
sop.error.usage.option_requires_other_option=Option '%s' is requested, but no option %s was provided.
|
||||
sop.error.usage.incompatible_options.clearsigned_no_armor=Options '--no-armor' and '--as=clearsigned' are incompatible.
|
||||
# Feature Support
|
||||
sop.error.feature_support.subcommand_not_supported=Subcommand '%s' is not supported.
|
||||
sop.error.feature_support.option_not_supported=Option '%s' not supported.
|
||||
sop.error.feature_support.option_not_supported=Option '%s' not supported.
|
||||
sop.error.feature_support.subcommand_does_not_support_profiles=Subcommand '%s' does not support any profiles.
|
|
@ -73,8 +73,10 @@ sop.error.runtime.cannot_decrypt_message=Nachricht konnte nicht entschl
|
|||
sop.error.usage.password_or_cert_required=Es wird mindestens ein Passwort und/oder Zertifikat zur Verschlüsselung benötigt.
|
||||
sop.error.usage.argument_required=Argument '%s' ist erforderlich.
|
||||
sop.error.usage.parameter_required=Parameter '%s' ist erforderlich.
|
||||
sop.error.usage.profile_not_supported=Unterbefehl '%s' unterstützt Profil '%s' nicht.
|
||||
sop.error.usage.option_requires_other_option=Option '%s' wurde angegeben, jedoch kein Wert für %s.
|
||||
sop.error.usage.incompatible_options.clearsigned_no_armor=Optionen '--no-armor' und '--as=clearsigned' sind inkompatibel.
|
||||
# Feature Support
|
||||
sop.error.feature_support.subcommand_not_supported=Unterbefehl '%s' wird nicht unterstützt.
|
||||
sop.error.feature_support.option_not_supported=Option '%s' wird nicht unterstützt.
|
||||
sop.error.feature_support.option_not_supported=Option '%s' wird nicht unterstützt.
|
||||
sop.error.feature_support.subcommand_does_not_support_profiles=Unterbefehl '%s' unterstützt keine Profile.
|
Loading…
Add table
Add a link
Reference in a new issue