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 28bde27..5f0e476 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 @@ -28,6 +28,10 @@ public class GenerateKeyCmd implements Runnable { @CommandLine.Parameters(description = "User-ID, eg. \"Alice \"") List userId = new ArrayList<>(); + @CommandLine.Option(names = "--with-key-password", + description = "Password to protect the key") + String withKeyPassword; + @Override public void run() { GenerateKey generateKey = SopCLI.getSop().generateKey(); @@ -43,6 +47,10 @@ public class GenerateKeyCmd implements Runnable { generateKey.noArmor(); } + if (withKeyPassword != null && !withKeyPassword.trim().isEmpty()) { + generateKey.withKeyPassword(withKeyPassword.trim()); + } + try { Ready ready = generateKey.generate(); ready.writeTo(System.out);