Class: FastlaneCore::Shell
- Defined in:
- lib/fastlane_core/ui/implementations/shell.rb
Overview
Shell is the terminal output of things For documentation for each of the methods open ‘interface.rb`
Messaging: show text to the user collapse
- #command(message) ⇒ Object
- #command_output(message) ⇒ Object
- #error(message) ⇒ Object
- #header(message) ⇒ Object
- #important(message) ⇒ Object
- #message(message) ⇒ Object
- #success(message) ⇒ Object
- #verbose(message) ⇒ Object
Errors: Inputs collapse
- #confirm(message) ⇒ Object
- #input(message) ⇒ Object
- #interactive? ⇒ Boolean
- #password(message) ⇒ Object
- #select(message, options) ⇒ Object
Errors: Different kinds of exceptions collapse
Instance Method Summary collapse
Methods inherited from Interface
Instance Method Details
#command(message) ⇒ Object
48 49 50 |
# File 'lib/fastlane_core/ui/implementations/shell.rb', line 48 def command() log.info("$ #{}".cyan.underline) end |
#command_output(message) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/fastlane_core/ui/implementations/shell.rb', line 52 def command_output() actual = (.split("\r").last || "") # as clearing the line will remove the `>` and the time stamp actual.split("\n").each do |msg| prefix = msg.include?("▸") ? "" : "▸ " log.info(prefix + "" + msg.magenta) end end |
#confirm(message) ⇒ Object
87 88 89 90 |
# File 'lib/fastlane_core/ui/implementations/shell.rb', line 87 def confirm() verify_interactive!() agree("#{} (y/n)", true) end |
#crash!(exception) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/fastlane_core/ui/implementations/shell.rb', line 109 def crash!(exception) if exception.kind_of?(String) raise exception.red elsif exception.kind_of?(Exception) # From https://stackoverflow.com/a/4789702/445598 # We do this to make the actual error message red and therefore more visible begin raise exception rescue => ex raise $!, "[!] #{ex.}".red, $!.backtrace end else raise exception # we're just raising whatever we have here #yolo end end |
#error(message) ⇒ Object
32 33 34 |
# File 'lib/fastlane_core/ui/implementations/shell.rb', line 32 def error() log.error(.red) end |
#header(message) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/fastlane_core/ui/implementations/shell.rb', line 64 def header() i = .length + 8 Helper.log.info(("-" * i).green) Helper.log.info(("--- " + + " ---").green) Helper.log.info(("-" * i).green) end |
#important(message) ⇒ Object
36 37 38 |
# File 'lib/fastlane_core/ui/implementations/shell.rb', line 36 def important() log.warn(.yellow) end |
#input(message) ⇒ Object
82 83 84 85 |
# File 'lib/fastlane_core/ui/implementations/shell.rb', line 82 def input() verify_interactive!() ask() end |
#interactive? ⇒ Boolean
75 76 77 78 79 80 |
# File 'lib/fastlane_core/ui/implementations/shell.rb', line 75 def interactive? interactive = true interactive = false if $stdout.isatty == false interactive = false if Helper.ci? return interactive end |
#log ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fastlane_core/ui/implementations/shell.rb', line 5 def log return @log if @log $stdout.sync = true if Helper.is_test? @log ||= Logger.new(nil) # don't show any logs when running tests else @log ||= Logger.new($stdout) end @log.formatter = proc do |severity, datetime, progname, msg| string = "#{severity} [#{datetime.strftime('%Y-%m-%d %H:%M:%S.%2N')}]: " if $verbose string = "[#{datetime.strftime('%H:%M:%S')}]: " unless $verbose string += "#{msg}\n" string end @log end |
#message(message) ⇒ Object
44 45 46 |
# File 'lib/fastlane_core/ui/implementations/shell.rb', line 44 def () log.info() end |
#password(message) ⇒ Object
99 100 101 102 103 |
# File 'lib/fastlane_core/ui/implementations/shell.rb', line 99 def password() verify_interactive!() ask(.yellow) { |q| q.echo = "*" } end |
#select(message, options) ⇒ Object
92 93 94 95 96 97 |
# File 'lib/fastlane_core/ui/implementations/shell.rb', line 92 def select(, ) verify_interactive!() important() choose(*()) end |
#success(message) ⇒ Object
40 41 42 |
# File 'lib/fastlane_core/ui/implementations/shell.rb', line 40 def success() log.info(.green) end |
#user_error!(error_message) ⇒ Object
125 126 127 128 129 130 131 132 133 |
# File 'lib/fastlane_core/ui/implementations/shell.rb', line 125 def user_error!() = "\n[!] #{}".red if $verbose # On verbose we want to see the full stack trace raise else abort() end end |
#verbose(message) ⇒ Object
60 61 62 |
# File 'lib/fastlane_core/ui/implementations/shell.rb', line 60 def verbose() log.debug() if $verbose end |