module Trustworthy::CLI::Crypt

Public Class Methods

included(klass) click to toggle source
# File lib/trustworthy/cli/crypt.rb, line 4
def self.included(klass)
  klass.extend(ClassMethods)
end

Public Instance Methods

_check_options(args) click to toggle source
# File lib/trustworthy/cli/crypt.rb, line 32
def _check_options(args)
  options = parse_options(args)
  unless options[:input_file] && options[:output_file]
    print_help
    throw :error
  end
  options
end
_command() click to toggle source
# File lib/trustworthy/cli/crypt.rb, line 28
def _command
  self.class._command
end
parse_options(args) click to toggle source
Calls superclass method
# File lib/trustworthy/cli/crypt.rb, line 8
def parse_options(args)
  options = super(_command, args) do |opts, inner_options|
    opts.on('-o', '--output FILE', "File to write #{_command}ed contents to") do |file|
      inner_options[:output_file] = file
    end
  end
  options[:input_file] = args.shift
  options
end
run(args) click to toggle source
# File lib/trustworthy/cli/crypt.rb, line 18
def run(args)
  catch(:error) do
    options = _check_options(args)
    prompt = Trustworthy::Prompt.new(options[:config_file], $terminal)
    File.open(options[:input_file], 'rb') do |input_file|
      _transform(prompt, options, input_file)
    end
  end
end