Class: Fastlane::Actions::PromptAction

Inherits:
Fastlane::Action show all
Defined in:
lib/fastlane/actions/prompt.rb

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, sh

Class Method Details

.authorsObject



49
50
51
# File 'lib/fastlane/actions/prompt.rb', line 49

def self.authors
  ["KrauseFx"]
end

.available_optionsObject



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fastlane/actions/prompt.rb', line 31

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :text,
                                 description: "The text that will be displayed to the user"),
    FastlaneCore::ConfigItem.new(key: :ci_input,
                                 description: "The default text that will be used when being executed on a CI service",
                                 default_value: ''),
    FastlaneCore::ConfigItem.new(key: :boolean,
                                 description: "Is that a boolean question (yes/no)? This will add (y/n) at the end",
                                 default_value: false,
                                 is_string: false)
  ]
end

.descriptionObject



20
21
22
# File 'lib/fastlane/actions/prompt.rb', line 20

def self.description
  "Ask the user for a value or for confirmation"
end

.detailsObject



24
25
26
27
28
29
# File 'lib/fastlane/actions/prompt.rb', line 24

def self.details
  [
    "You can use `prompt` to ask the user for a value or to just let the user confirm the next step",
    "When this is executed on a CI service, the passed `ci_input` value will be returned"
  ].join("\n")
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/fastlane/actions/prompt.rb', line 53

def self.is_supported?(platform)
  true
end

.outputObject



45
46
47
# File 'lib/fastlane/actions/prompt.rb', line 45

def self.output
  []
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/fastlane/actions/prompt.rb', line 4

def self.run(params)
  params[:text] += " (y/n)" if params[:boolean]
  Helper.log.info params[:text]

  user_input = params[:ci_input] if Helper.is_ci?
  user_input ||= STDIN.gets.chomp.strip

  user_input = (user_input.downcase == 'y') if params[:boolean]

  return user_input
end