Class: FastlaneCore::Shell
- Inherits:
 - 
      Object
      
        
- Object
 - FastlaneCore::Shell
 
 
- Defined in:
 - lib/fastlane/plugin/wpmreleasetoolkit/helper/interactive_prompt_reminder.rb
 
Overview
NOTE: FastlaneCore::UI delegates to the FastlaneCore::Shell implementation when output is the terminal
Constant Summary collapse
- DEFAULT_PROMPT_REMINDER_MESSAGE =
 'An interactive prompt is waiting for you in the Terminal!'- DEFAULT_PROMPT_REMINDER_DELAYS =
 [30, 180, 600].freeze
Class Method Summary collapse
- 
  
    
      .monkey_patch_interactive_prompts_with_reminder(after: DEFAULT_PROMPT_REMINDER_DELAYS, message: DEFAULT_PROMPT_REMINDER_MESSAGE)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Monkey-Patch fastlane’s ‘UI.input`, `UI.confirm`, `UI.select` and `UI.password` interactive methods (which delegate to `FastlaneCore::Shell` when output is the terminal).
 - 
  
    
      .with_reminder(after: DEFAULT_PROMPT_REMINDER_DELAYS, message: DEFAULT_PROMPT_REMINDER_MESSAGE)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Calls the block given and remind the user with a vocal message if the block does not return after specific delays.
 
Class Method Details
.monkey_patch_interactive_prompts_with_reminder(after: DEFAULT_PROMPT_REMINDER_DELAYS, message: DEFAULT_PROMPT_REMINDER_MESSAGE) ⇒ Object
Monkey-Patch fastlane’s ‘UI.input`, `UI.confirm`, `UI.select` and `UI.password` interactive methods (which delegate to `FastlaneCore::Shell` when output is the terminal)
Once you call this method, any invocation of ‘UI.input`, `UI.confirm`, `UI.select` or `UI.password` anywhere in Fastlane (by your Fastfile, an action, …) will be wrapped in a call to with_reminder automatically.
      75 76 77 78 79 80 81 82 83  | 
    
      # File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/interactive_prompt_reminder.rb', line 75 def self.monkey_patch_interactive_prompts_with_reminder(after: DEFAULT_PROMPT_REMINDER_DELAYS, message: DEFAULT_PROMPT_REMINDER_MESSAGE) %i[input confirm select password].each do |method_name| old_method = instance_method(method_name) define_method(method_name) do |*args| FastlaneCore::Shell.with_reminder(after: after, message: ) { old_method.bind(self).call(*args) } end end end  | 
  
.with_reminder(after: DEFAULT_PROMPT_REMINDER_DELAYS, message: DEFAULT_PROMPT_REMINDER_MESSAGE) ⇒ Object
Calls the block given and remind the user with a vocal message if the block does not return after specific delays.
Especially useful when using a block which calls methods that are interactive, in order to remind the user to answer the interactive prompt if they forgot about it after some delays.
Example usage:
text = with_reminder do
  puts "Enter some text:"
  $stdout.getch
end
  
      52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67  | 
    
      # File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/interactive_prompt_reminder.rb', line 52 def self.with_reminder(after: DEFAULT_PROMPT_REMINDER_DELAYS, message: DEFAULT_PROMPT_REMINDER_MESSAGE) delays_list = Array(after.dup) thread = Thread.new do until delays_list.empty? sleep(delays_list.shift) $stdout.beep system('say', ) unless .nil? end end # execute the interactive code res = yield # if we replied before the timeout, kill the thread so message won't be triggered thread.kill # If the block given returned a value, pass it res end  |