Sha256: f954f81f5afd9819a8e4d1b95976b10de779ee7063a1fc69ba9311f8b4a34a34

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

require "keyring_liberator"
require "name_whisperer"

module Pod
  class Command
    class Keys

      class Get < Keys
        self.summary = "Print a values of a key."

        self.description = <<-DESC
            Outputs the value of a key to SDTOUT

            A second optional operator can be done to force a project name.
        DESC

        self.arguments = [CLAide::Argument.new('key', true),
                          CLAide::Argument.new('project_name', false)]

        def initialize(argv)
          @key_name = argv.shift_argument
          @project_name = argv.shift_argument
          super
        end

        def validate!
          super
          verify_podfile_exists!
          help! "A key name is required for lookup." unless @key_name
        end

        def run
          keyring = get_current_keyring
          if !keyring
            $stderr.puts "Could not find a project for this folder"
            return
          end

          if keyring.keys.include? @key_name
            data = keyring.keychain_data
            puts data[@key_name]
          else
            $stderr.puts "Could not find value"
          end
        end

        def get_current_keyring
          current_dir = Dir.getwd
          keyring = CocoaPodsKeys::KeyringLiberator.get_keyring current_dir
          if !keyring && @project_name
            return CocoaPodsKeys::KeyringLiberator.get_keyring_named @project_name
          end
          keyring
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cocoapods-keys-1.2.1 lib/pod/command/keys/get.rb
cocoapods-keys-1.2.0 lib/pod/command/keys/get.rb