Sha256: 7f7523c5193c9fe7274d2bc49129bd055aaeeaa83c8a6f2a4f5fc2e66b6d6c38

Contents?: true

Size: 766 Bytes

Versions: 11

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

11 entries across 11 versions & 1 rubygems

Version Path
sym-3.0.2 lib/sym/app/commands/generate_key.rb
sym-3.0.1 lib/sym/app/commands/generate_key.rb
sym-3.0.0 lib/sym/app/commands/generate_key.rb
sym-2.10.0 lib/sym/app/commands/generate_key.rb
sym-2.8.5 lib/sym/app/commands/generate_key.rb
sym-2.8.4 lib/sym/app/commands/generate_key.rb
sym-2.8.2 lib/sym/app/commands/generate_key.rb
sym-2.8.1 lib/sym/app/commands/generate_key.rb
sym-2.8.0 lib/sym/app/commands/generate_key.rb
sym-2.7.0 lib/sym/app/commands/generate_key.rb
sym-2.6.3 lib/sym/app/commands/generate_key.rb