Sha256: ff4c53b0189ed55eef2b06a6b207009f92f890e553241a1e7ba1102a9cba62dd

Contents?: true

Size: 1.93 KB

Versions: 131

Compression:

Stored size: 1.93 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.'

      global_option('--env STRING[,STRING2]', String, 'Add environment(s) to use with `dotenv`')

      # 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

131 entries across 131 versions & 4 rubygems

Version Path
fastlane-2.226.0 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.225.0 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.224.0 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.223.1 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.223.0 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.222.0 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.221.1 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.221.0 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.220.0 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.219.0 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.218.0 credentials_manager/lib/credentials_manager/cli.rb
fastlane-security-patched-2.216.0 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.217.0 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.216.0 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.215.1 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.215.0 credentials_manager/lib/credentials_manager/cli.rb
fastlane-mercafacil-2.214.0 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.214.0 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.213.0 credentials_manager/lib/credentials_manager/cli.rb
fastlane-2.212.2 credentials_manager/lib/credentials_manager/cli.rb