Sha256: 4cc04290baa715306eb8e2f43fe722ecc9062658508ed793578a341ca7682153

Contents?: true

Size: 893 Bytes

Versions: 6

Compression:

Stored size: 893 Bytes

Contents

# frozen_string_literal: true

require 'travis/cli'

module Travis
  module CLI
    class Pubkey < RepoCommand
      attr_accessor :key_format

      description "prints out a repository's public key"
      on('-p', '--pem', 'encode in format used by pem') { |c, _| c.key_format = :pem }
      on('-f', '--fingerprint', 'display fingerprint')  { |c, _| c.key_format = :fingerprint }

      def run
        error "#{key_format} format not supported by #{api_endpoint}" unless key
        say key, "Public key for #{color(repository.slug, :info)}:\n\n%s", :bold
      end

      private

      def key
        key = repository.public_key
        case self.key_format ||= :ssh
        when :fingerprint then key.fingerprint
        when :pem         then key.to_s
        when :ssh         then key.to_ssh
        else raise "unknown format #{key_format}"
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
travis-1.14.0 lib/travis/cli/pubkey.rb
travis-1.13.3 lib/travis/cli/pubkey.rb
travis-1.13.2 lib/travis/cli/pubkey.rb
travis-1.13.1 lib/travis/cli/pubkey.rb
travis-1.13.0 lib/travis/cli/pubkey.rb
travis-1.12.0 lib/travis/cli/pubkey.rb