Class: Fastlane::Actions::FivSelectClientAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/fivethree_ionic/actions/fiv_select_client.rb

Class Method Summary collapse

Class Method Details

.authorObject



80
81
82
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_select_client.rb', line 80

def self.author
  'Marc'
end

.available_optionsObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_select_client.rb', line 44

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 SelectClientAction 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
    ),
    FastlaneCore::ConfigItem.new(
      key: :client,
      env_name: 'FIV_CLIENT',
      # The name of the environment variable
      description: 'client to select',
      # a short description of this parameter"
      is_string: true,
      optional: true
    )
  ]
end

.descriptionObject



40
41
42
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_select_client.rb', line 40

def self.description
  'Select a client'
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_select_client.rb', line 84

def self.is_supported?(platform)
  i[ios mac android].include? platform
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_select_client.rb', line 4

def self.run(params)
  Dir.chdir "#{params[:clients_folder]}" do
    clients_folders = Dir.glob('*').sort.select { |f| File.directory? f }
    client = ENV['CLIENT'] || params[:client]
    if (client)
      if (clients_folders.include?(client))
        puts(
          "
                ***********************************************
                  Selected client: #{
            client
          }
                ***********************************************
                "
        )
        return client
      else
        UI.user_error!("Client #{client} is not available.")
      end
    end

    selected_client = UI.select('Select one client: ', clients_folders)

    puts(
      "
          ***********************************************
              Selected client: #{
        selected_client
      }
          ***********************************************
          "
    )
    return selected_client
  end
end