Sha256: 83804ffc1768ad068a3748dae86576129ebc1ba4cb0135b86df493ae68987374

Contents?: true

Size: 815 Bytes

Versions: 1

Compression:

Stored size: 815 Bytes

Contents

require_relative 'command'
require 'sym/app/keychain'
module Sym
  module App
    module Commands
      class GenerateKey < Command
        include Sym

        required_options :generate

        def execute
          retries         ||= 0
          new_private_key = self.class.create_private_key
          new_private_key = encr_password(new_private_key,
                                          application.input_handler.new_password) if opts[:password]

          Sym::App::KeyChain.new(opts[:keychain], opts).
            add(new_private_key) if opts[:keychain] && Sym::App.is_osx?

          new_private_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

1 entries across 1 versions & 1 rubygems

Version Path
sym-2.0.3 lib/sym/app/commands/generate_key.rb