exe/openpgpkeysrecord
#!/usr/bin/env ruby
require 'bundler/setup'
require 'optparse'
require 'ostruct'
require 'cryptorecord/openpgpkeys'
options = OpenStruct.new
OptionParser.new do |opt|
opt.banner = "Usage: #{$PROGRAM_NAME} -u <email> -f <gpgkeyfile>"
opt.on('-h', '--help', 'This help screen') do
warn opt
exit
end
opt.on('-f', '--publickeyfile PGP-PUBLICKEY-FILE',
'PGP-Publickey-File') { |o| options.keyfile = o }
opt.on('-u', '--uid EMAIL', 'email-address') { |o| options.uid = o }
# this won't work with older ruby-versions
options[:help] = opt.help
end.parse!
unless defined? options.keyfile
warn 'Usage-Error: No keyfile provided'
exit 1
end
unless defined? options.uid
warn 'Usage-Error: No uid provided'
exit 1
end
openpgpkeys = Cryptorecord::Openpgpkey.new(options.to_h)
openpgpkeys.read_file(options.keyfile)
puts openpgpkeys