Sha256: 7e32417538ffc928d9dfeac1049ba9417375fc53c2eb625a4502fe2a6c0c1fdf

Contents?: true

Size: 766 Bytes

Versions: 7

Compression:

Stored size: 766 Bytes

Contents

require 'sym/app/commands/base_command'
require 'sym/app/keychain'
module Sym
  module App
    module Commands
      class GenerateKey < BaseCommand

        required_options :generate

        try_after :show_help

        def execute
          retries ||= 0

          the_key = create_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

7 entries across 7 versions & 1 rubygems

Version Path
sym-2.6.2 lib/sym/app/commands/generate_key.rb
sym-2.6.1 lib/sym/app/commands/generate_key.rb
sym-2.6.0 lib/sym/app/commands/generate_key.rb
sym-2.5.3 lib/sym/app/commands/generate_key.rb
sym-2.5.1 lib/sym/app/commands/generate_key.rb
sym-2.5.0 lib/sym/app/commands/generate_key.rb
sym-2.4.3 lib/sym/app/commands/generate_key.rb