Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deserialize subcommand to EncryptionPublicKeys tool. #1191

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import picocli.CommandLine
*/
@CommandLine.Command(
description = ["Utility for EncryptionPublicKey messages."],
subcommands = [CommandLine.HelpCommand::class, Serialize::class, Sign::class]
subcommands = [CommandLine.HelpCommand::class, Serialize::class, Deserialize::class, Sign::class]
)
class EncryptionPublicKeys private constructor() : Runnable {
override fun run() {
Expand Down Expand Up @@ -74,6 +74,25 @@ private class Serialize : Runnable {
}
}

@CommandLine.Command(name = "deserialize", showDefaultValues = true)
private class Deserialize : Runnable {
@CommandLine.Option(
names = ["--in", "-i"],
description = ["Input File containing EncryptionPublicKey message"],
required = true
)
private lateinit var input: File

@CommandLine.Option(names = ["--out", "-o"], description = ["Output file"], required = true)
private lateinit var output: File

override fun run() {
val message = input.inputStream().use { EncryptionPublicKey.parseFrom(it) }

output.outputStream().use { message.data.writeTo(it) }
}
}

@CommandLine.Command(name = "sign")
private class Sign : Runnable {
@CommandLine.Option(
Expand Down