GenerateKeyCmd: Do not assert default profile

This commit is contained in:
Paul Schaub 2023-04-14 15:01:50 +02:00
parent 19663c4dec
commit d38556f79a
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -32,13 +32,22 @@ public class GenerateKeyCmd extends AbstractSopCmd {
@CommandLine.Option(names = "--profile", @CommandLine.Option(names = "--profile",
paramLabel = "PROFILE") paramLabel = "PROFILE")
String profile = "default"; String profile;
@Override @Override
public void run() { public void run() {
GenerateKey generateKey = throwIfUnsupportedSubcommand( GenerateKey generateKey = throwIfUnsupportedSubcommand(
SopCLI.getSop().generateKey(), "generate-key"); SopCLI.getSop().generateKey(), "generate-key");
if (profile != null) {
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);
}
}
for (String userId : userId) { for (String userId : userId) {
generateKey.userId(userId); generateKey.userId(userId);
} }
@ -47,13 +56,6 @@ public class GenerateKeyCmd extends AbstractSopCmd {
generateKey.noArmor(); generateKey.noArmor();
} }
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) { if (withKeyPassword != null) {
try { try {
String password = stringFromInputStream(getInput(withKeyPassword)); String password = stringFromInputStream(getInput(withKeyPassword));