Sha256: d4db9aa564febfcec4cb4739425bcf253c32fb838ef28e4675135383a1d42f31

Contents?: true

Size: 1.79 KB

Versions: 441

Compression:

Stored size: 1.79 KB

Contents

require 'commander'

module CredentialsManager
  class CLI
    include Commander::Methods

    # Parses command options and executes actions
    def run
      program :name, 'CredentialsManager'
      program :version, Fastlane::VERSION
      program :description, 'Manage credentials for fastlane tools.'

      # Command to add entry to Keychain
      command :add do |c|
        c.syntax = 'fastlane fastlane-credentials add'
        c.description = 'Adds a fastlane credential to the keychain.'

        c.option '--username username', String, 'Username to add.'
        c.option '--password password', String, 'Password to add.'

        c.action do |args, options|
          username = options.username || ask('Username: ')
          password = options.password || ask('Password: ') { |q| q.echo = '*' }

          add(username, password)

          puts "Credential #{username}:#{'*' * password.length} added to keychain."
        end
      end

      # Command to remove credential from Keychain
      command :remove do |c|
        c.syntax = 'fastlane fastlane-credentials remove'
        c.description = 'Removes a fastlane credential from the keychain.'

        c.option '--username username', String, 'Username to remove.'

        c.action do |args, options|
          username = options.username || ask('Username: ')

          remove(username)
        end
      end

      run!
    end

    private

    # Add entry to Apple Keychain using AccountManager
    def add(username, password)
      CredentialsManager::AccountManager.new(
        user: username,
        password: password
      ).add_to_keychain
    end

    # Remove entry from Apple Keychain using AccountManager
    def remove(username)
      CredentialsManager::AccountManager.new(
        user: username
      ).remove_from_keychain
    end
  end
end

Version data entries

441 entries across 441 versions & 1 rubygems

Version Path
fastlane-2.74.0.beta.20180106010004 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.73.0 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.73.0.beta.20180105010003 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.73.0.beta.20180104010004 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.73.0.beta.20180103010003 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.72.0 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.72.0.beta.20180102010003 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.72.0.beta.20180101010003 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.72.0.beta.20171231010003 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.71.1 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.72.0.beta.20171230010003 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.72.0.beta.20171229010003 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.72.0.beta.20171228010004 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.71.0 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.71.0.beta.20171227010004 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.71.0.beta.20171226010004 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.71.0.beta.20171225010003 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.71.0.beta.20171224010003 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.71.0.beta.20171223010003 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.71.0.beta.20171222010003 credentials_manager/lib/credentials_manager/cli.rb