mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2025-09-09 10:19:47 +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
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
# SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
usage.header=Emit a list of profiles supported by the identified subcommand
|
||||
subcommand=Subcommand for which to list profiles
|
||||
# Generic TODO: Remove when bumping picocli to 4.7.0
|
||||
usage.synopsisHeading=Usage:\u0020
|
||||
usage.commandListHeading = %nCommands:%n
|
||||
usage.optionListHeading = %nOptions:%n
|
||||
usage.footerHeading=Powered by picocli%n
|
|
@ -0,0 +1,10 @@
|
|||
# SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
usage.header=Gebe eine Liste von Profilen aus, welche vom angegebenen Unterbefehl unterstützt werden
|
||||
subcommand=Unterbefehl für welchen Profile gelistet werden sollen
|
||||
# Generic TODO: Remove when bumping picocli to 4.7.0
|
||||
usage.synopsisHeading=Aufruf:\u0020
|
||||
usage.commandListHeading=%nBefehle:%n
|
||||
usage.optionListHeading = %nOptionen:%n
|
||||
usage.footerHeading=Powered by Picocli%n
|
|
@ -26,6 +26,7 @@ import sop.operation.InlineSign;
|
|||
import sop.operation.InlineVerify;
|
||||
import sop.operation.DetachedSign;
|
||||
import sop.operation.DetachedVerify;
|
||||
import sop.operation.ListProfiles;
|
||||
import sop.operation.Version;
|
||||
|
||||
public class SOPTest {
|
||||
|
@ -95,6 +96,11 @@ public class SOPTest {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListProfiles listProfiles() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InlineDetach inlineDetach() {
|
||||
return null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue