class Fastlane::Actions::FivSelectClientsAction

Public Class Methods

author() click to toggle source
# File lib/fastlane/plugin/fivethree_ionic/actions/fiv_select_clients.rb, line 88
def self.author
  'Marc'
end
available_options() click to toggle source
# File lib/fastlane/plugin/fivethree_ionic/actions/fiv_select_clients.rb, line 61
def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :clients_folder,
      env_name: 'FIV_CLIENTS_FOLDER',
      # The name of the environment variable
      description: 'Clients folder path for SelectClientAction',
      # a short description of this parameter
      default_value: 'clients',
      is_string: true,
      verify_block:
        proc do |value|
          unless (value and not value.empty?)
            UI.user_error!(
              "No client folder path for FivSelectClientAction given, pass using `client_folder: '../path_to_clients_folder'`"
            )
          end
          unless File.directory?(value)
            UI.user_error!(
              "Couldn't find clients folder at path '#{value}'"
            )
          end
        end
    )
  ]
end
description() click to toggle source
# File lib/fastlane/plugin/fivethree_ionic/actions/fiv_select_clients.rb, line 57
def self.description
  'Select list of clients'
end
is_supported?(platform) click to toggle source
# File lib/fastlane/plugin/fivethree_ionic/actions/fiv_select_clients.rb, line 92
def self.is_supported?(platform)
  %i[ios mac android].include? platform
end
run(params) click to toggle source
# File lib/fastlane/plugin/fivethree_ionic/actions/fiv_select_clients.rb, line 4
def self.run(params)
  clients = []
  Dir.chdir "#{params[:clients_folder]}" do
    clients_folders = Dir.glob('*').sort.select { |f| File.directory? f }

    if (ENV['CLIENTS'])
      envClients = ENV['CLIENTS'].split(',')
      selectedClients =
        envClients.select { |x| clients_folders.include?(x) }
      puts(
        "
                  ***********************************************
                      Selected clients: #{
          selectedClients
        }
                  ***********************************************
                  "
      )
      return selectedClients
    end

    clients_folders.unshift('All')
    selected_client = UI.select('Select clients: ', clients_folders)

    if (selected_client === 'All')
      clients_folders.shift
      puts(
        "
                  ***********************************************
                      Selected clients: #{
          clients_folders
        }
                  ***********************************************
                  "
      )
      return clients_folders
    end

    puts(
      "
              ***********************************************
                  Selected client: #{
        selected_client
      }
              ***********************************************
              "
    )
    clients.push(selected_client)
  end

  return clients
end