Sha256: 91e0375975a5f142655a469bc0534105b7c325049123954dfc37448bfd4629e7

Contents?: true

Size: 1.53 KB

Versions: 12

Compression:

Stored size: 1.53 KB

Contents

require 'keyring_liberator'

module Pod
  class Command
    class Keys
      class List < Keys
        self.summary = 'Lists all known keys and values.'

        self.description = <<-DESC
          Shows all the current keys and values for your current working directory.

          Also lists all known projects with variable stores.
        DESC

        def run
          # List all settings for current app
          this_keyring = get_current_keyring
          if this_keyring
            display_current_keyring this_keyring
          end

          # List all known bundle ids
          all_keyrings = CocoaPodsKeys::KeyringLiberator.get_all_keyrings
          all_keyrings.each do |keyring|
            display_keyring(keyring) if !this_keyring || keyring.path != this_keyring.path
          end
        end

        def display_current_keyring(keyring)
          UI.puts "Keys for #{keyring.name}"
          data = keyring.keychain_data
          data.each_with_index do |(key, value), index|
            prefix = index == data.length - 1 ? ' └ ' : ' ├ '
            UI.puts prefix + " #{key} - #{value}"
          end
          UI.puts
        end

        def display_keyring(keyring)
          UI.puts "#{keyring.name} - #{keyring.path}"
          if keyring.keys.empty?
            # Skip
          elsif keyring.keys.length == 1
            UI.puts ' └ ' + keyring.keys[0]
          else
            UI.puts ' └ ' + keyring.keys[0...-1].join(' ') + ' & ' + keyring.keys[-1]
          end
          UI.puts
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
cocoapods-keys-2.3.1 lib/pod/command/keys/list.rb
cocoapods-keys-2.3.0 lib/pod/command/keys/list.rb
cocoapods-keys-2.2.1 lib/pod/command/keys/list.rb
cocoapods-keys-2.2.0 lib/pod/command/keys/list.rb
cocoapods-keys-2.1.0 lib/pod/command/keys/list.rb
cocoapods-keys-2.0.7 lib/pod/command/keys/list.rb
cocoapods-keys-2.0.6 lib/pod/command/keys/list.rb
cocoapods-keys-2.0.5 lib/pod/command/keys/list.rb
cocoapods-keys-2.0.4 lib/pod/command/keys/list.rb
cocoapods-keys-2.0.3 lib/pod/command/keys/list.rb
cocoapods-keys-2.0.2 lib/pod/command/keys/list.rb
cocoapods-keys-2.0.1 lib/pod/command/keys/list.rb