#!/usr/bin/env ruby $VERBOSE = true require 'optparse' require_relative '../lib/paperback' BaseName = File.basename($0) def main options = {} optparse = OptionParser.new do |opts| opts.banner = <<-EOM usage: #{BaseName} [OPTION]... INPUT OUT_PDF Create a printable PDF backup of INPUT file and write to OUT_PDF. The saved PDF file will be suitable for printing. By default, the paper backup will contain the input data encoded as a QR code for ease of scanning and as sixword-encoded English text for more natural paper printing. In order to prevent the input content from being exposed to the printer, by default, the input content will be encrypted with a symmetric passphrase that is echoed to the terminal. There will be a placeholder in the PDF where you can manually add the passphrase by hand and pen. For example: # Create a backup of secret.key in backup.pdf #{BaseName} secret.key backup.pdf Options: EOM opts.on('-h', '--help', 'Display this message') do STDERR.puts opts, '' exit 0 end opts.on('--version', 'Print version number') do puts 'paperback ' + Paperback::VERSION exit 0 end opts.on('-v', '--verbose', 'Be more verbose', ' ') do Paperback.log_level -= 1 end # opts.on('-c', '--comment TEXT', 'Add TEXT comment to output') do |val| options[:comment] = val end opts.on('--no-encrypt', 'Skip encryption of input') do |val| options[:encrypt] = val end opts.on('--no-base64', "Don't append plain Base64 paragraph") do |val| options[:include_base64] = val end opts.on('--passphrase-out FILE', 'Write generated passphrase to FILE', ' ') do |val| options[:passphrase_file] = val end # opts.on('--sixword-font-size SIZE', 'Size of sixword text') do |val| options[:extra_draw_opts] ||= {} options[:extra_draw_opts][:sixword_font_size] = Float(val) end end optparse.parse! case ARGV.length when 2 options[:input] = ARGV.fetch(0) options[:output] = ARGV.fetch(1) else STDERR.puts optparse, '' exit 1 end Paperback::CLI.create_backup(**options) end main