Sha256: c48ef335f2c870c16952fbc550a04a32ed6bdc1aec671cab29f479bfc0a55c33

Contents?: true

Size: 865 Bytes

Versions: 2

Compression:

Stored size: 865 Bytes

Contents

require 'sym/app/commands/base_command'

module Sym
  module App
    module Commands
      class PasswordProtectKey < BaseCommand

        required_options %i(key interactive), :password
        incompatible_options %i(examples help version bash_completion)
        try_after :generate_key, :encrypt, :decrypt

        def execute
          retries ||= 0

          the_key = self.key

          if opts[:password]
             encrypted_key, password = encrypt_with_password(the_key)
             add_password_to_the_cache(encrypted_key, password)
             the_key = encrypted_key
           end

          add_to_keychain_if_needed(the_key)

          the_key
        rescue Sym::Errors::PasswordsDontMatch, Sym::Errors::PasswordTooShort => e
          STDERR.puts e.message.bold
          retry if (retries += 1) < 3
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sym-2.5.0 lib/sym/app/commands/password_protect_key.rb
sym-2.4.3 lib/sym/app/commands/password_protect_key.rb