Sha256: 383957ff363d87eb73e86a92858d8c01d7e43c1dbaa35a54a7344722005f804b

Contents?: true

Size: 1.83 KB

Versions: 526

Compression:

Stored size: 1.83 KB

Contents

require 'commander'

require_relative 'account_manager'

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

526 entries across 526 versions & 2 rubygems

Version Path
fastlane-2.87.0.beta.20180320050108 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.86.0 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.86.0.beta.20180319050058 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.86.0.beta.20180318050106 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.86.0.beta.20180317050040 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.86.0.beta.20180316050051 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.86.0.beta.20180315050105 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.86.0.beta.20180314050053 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.86.0.beta.20180313050023 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.86.0.beta.20180312050111 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.86.0.beta.20180311050103 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.86.0.beta.20180310050010 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.86.0.beta.20180309050025 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.85.0 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.85.0.beta.20180308050114 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.85.0.beta.20180307050101 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.85.0.beta.20180306050019 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.85.0.beta.20180305050037 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.85.0.beta.20180304050031 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.85.0.beta.20180303050048 credentials_manager/lib/credentials_manager/cli.rb