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: 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("$ #{message}".cyan.underline) end |
#command_output(message) ⇒ Object
52 53 54 55 56 57 |
# 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| log.info("> #{msg}".magenta) end end |
#crash!(exception) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/fastlane_core/ui/implementations/shell.rb', line 74 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.message}".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
63 64 65 66 67 68 |
# File 'lib/fastlane_core/ui/implementations/shell.rb', line 63 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 |
#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 |
#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
90 91 92 93 94 95 96 97 98 |
# File 'lib/fastlane_core/ui/implementations/shell.rb', line 90 def user_error!() = "[!] #{error_message}".red if $verbose # On verbose we want to see the full stack trace raise else abort() end end |
#verbose(message) ⇒ Object
59 60 61 |
# File 'lib/fastlane_core/ui/implementations/shell.rb', line 59 def verbose() log.debug() if $verbose end |