Commit e38823e0 authored by Drew's avatar Drew

Add GetSecretIdentity command

We need this to get identities for environment variables / CI
parent 2155a0bf
......@@ -76,6 +76,19 @@ private final class GetPublicIdentity : CLIKit.EasyCommand {
}
}
private final class GetSecretIdentity : CLIKit.EasyCommand {
fileprivate let options : [Option] = [identityOption]
fileprivate let shortHelp = "Get the secret portion of your identity, suitable for FISA_IDENTITY environment variable"
let name = "getSecretIdentity"
fileprivate func command(_ parseResult: ParseResult) {
//NaOH does not provide a mechanism to read private key bytes, for good reason
//use foundation instead
let url = URL(fileURLWithPath: parseResult[StringlyTyped.identityFile.rawValue].stringValue)
let f = try! Data(contentsOf: url)
print("\(f.base64EncodedString())")
}
}
private final class AddPublicIdentity : CLIKit.EasyCommand {
fileprivate let options : [Option] = [identityOption, fisaFileOption, DefaultOption(longName: StringlyTyped.publicIdentity.rawValue, help: "Public identity string to add"), DefaultOption(longName: StringlyTyped.identityDescription.rawValue, help: "The description to use for the new identity in the FISA file.")]
fileprivate let shortHelp = "Add the public portion of an identity to the specified FISA file"
......@@ -140,7 +153,7 @@ private final class GetSecret : CLIKit.EasyCommand {
}
let _ = FISAKit.registerText
let metaCommand = MetaCommand(name: "fisa", version: "2.0", subcommands: [IdentityCreationCommand(), CreateFISACommand(), PrintFISACommand(), GetPublicIdentity(), AddPublicIdentity(), RemovePublicIdentity(), SetSecret(), RemoveSecret(), GetSecret()])
let metaCommand = MetaCommand(name: "fisa", version: "2.0", subcommands: [IdentityCreationCommand(), CreateFISACommand(), PrintFISACommand(), GetPublicIdentity(), GetSecretIdentity(), AddPublicIdentity(), RemovePublicIdentity(), SetSecret(), RemoveSecret(), GetSecret()])
if let parseResult = metaCommand.parseArguments() {
metaCommand.command(parseResult)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment