Sha256: fce98aec5bf486592ab719f61f95888bf1685f0b5e1fb1d561eb9cbbd81482b7

Contents?: true

Size: 862 Bytes

Versions: 5

Compression:

Stored size: 862 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_support)
        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

5 entries across 5 versions & 1 rubygems

Version Path
sym-2.6.2 lib/sym/app/commands/password_protect_key.rb
sym-2.6.1 lib/sym/app/commands/password_protect_key.rb
sym-2.6.0 lib/sym/app/commands/password_protect_key.rb
sym-2.5.3 lib/sym/app/commands/password_protect_key.rb
sym-2.5.1 lib/sym/app/commands/password_protect_key.rb