From d38556f79aa4b2f4e7e66caeaf6814a62619d0d9 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Fri, 14 Apr 2023 15:01:50 +0200 Subject: [PATCH] GenerateKeyCmd: Do not assert default profile --- .../cli/picocli/commands/GenerateKeyCmd.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/sop-java-picocli/src/main/java/sop/cli/picocli/commands/GenerateKeyCmd.java b/sop-java-picocli/src/main/java/sop/cli/picocli/commands/GenerateKeyCmd.java index 1d08b7c..aac7124 100644 --- a/sop-java-picocli/src/main/java/sop/cli/picocli/commands/GenerateKeyCmd.java +++ b/sop-java-picocli/src/main/java/sop/cli/picocli/commands/GenerateKeyCmd.java @@ -32,13 +32,22 @@ public class GenerateKeyCmd extends AbstractSopCmd { @CommandLine.Option(names = "--profile", paramLabel = "PROFILE") - String profile = "default"; + String profile; @Override public void run() { GenerateKey generateKey = throwIfUnsupportedSubcommand( 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) { generateKey.userId(userId); } @@ -47,13 +56,6 @@ public class GenerateKeyCmd extends AbstractSopCmd { 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) { try { String password = stringFromInputStream(getInput(withKeyPassword));