mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2025-09-14 12:49:44 +02:00
Add list-profiles command
This commit is contained in:
parent
17b305924c
commit
83a003e80f
14 changed files with 216 additions and 0 deletions
|
@ -16,6 +16,7 @@ import sop.cli.picocli.commands.ExtractCertCmd;
|
|||
import sop.cli.picocli.commands.GenerateKeyCmd;
|
||||
import sop.cli.picocli.commands.InlineSignCmd;
|
||||
import sop.cli.picocli.commands.InlineVerifyCmd;
|
||||
import sop.cli.picocli.commands.ListProfilesCmd;
|
||||
import sop.cli.picocli.commands.SignCmd;
|
||||
import sop.cli.picocli.commands.VerifyCmd;
|
||||
import sop.cli.picocli.commands.VersionCmd;
|
||||
|
@ -41,6 +42,7 @@ import java.util.ResourceBundle;
|
|||
VerifyCmd.class,
|
||||
InlineSignCmd.class,
|
||||
InlineVerifyCmd.class,
|
||||
ListProfilesCmd.class,
|
||||
VersionCmd.class,
|
||||
AutoComplete.GenerateCompletion.class
|
||||
}
|
||||
|
|
|
@ -30,6 +30,10 @@ public class GenerateKeyCmd extends AbstractSopCmd {
|
|||
paramLabel = "PASSWORD")
|
||||
String withKeyPassword;
|
||||
|
||||
@CommandLine.Option(names = "--profile",
|
||||
paramLabel = "PROFILE")
|
||||
String profile = "default";
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
GenerateKey generateKey = throwIfUnsupportedSubcommand(
|
||||
|
@ -43,6 +47,8 @@ public class GenerateKeyCmd extends AbstractSopCmd {
|
|||
generateKey.noArmor();
|
||||
}
|
||||
|
||||
generateKey.profile(profile);
|
||||
|
||||
if (withKeyPassword != null) {
|
||||
try {
|
||||
String password = stringFromInputStream(getInput(withKeyPassword));
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sop.cli.picocli.commands;
|
||||
|
||||
import picocli.CommandLine;
|
||||
import sop.cli.picocli.SopCLI;
|
||||
import sop.operation.ListProfiles;
|
||||
|
||||
@CommandLine.Command(name = "list-profiles",
|
||||
resourceBundle = "msg_list-profiles",
|
||||
exitCodeOnInvalidInput = 37)
|
||||
public class ListProfilesCmd extends AbstractSopCmd {
|
||||
|
||||
@CommandLine.Parameters(paramLabel = "COMMAND", arity="0..1", descriptionKey = "subcommand")
|
||||
String subcommand;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ListProfiles listProfiles = throwIfUnsupportedSubcommand(
|
||||
SopCLI.getSop().listProfiles(), "list-profiles");
|
||||
|
||||
if (subcommand == null) {
|
||||
for (String profile : listProfiles.global()) {
|
||||
// CHECKSTYLE:OFF
|
||||
System.out.println(profile);
|
||||
// CHECKSTYLE:ON
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for (String profile : listProfiles.ofCommand(subcommand)) {
|
||||
// CHECKSTYLE:OFF
|
||||
System.out.println(profile);
|
||||
// CHECKSTYLE:ON
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue