class FastlaneCore::Shell

Shell is the terminal output of things For documentation for each of the methods open `interface.rb`

Public Instance Methods

command(message) click to toggle source
# File lib/fastlane_core/ui/implementations/shell.rb, line 57
def command(message)
  log.info("$ #{message}".cyan.underline)
end
command_output(message) click to toggle source
# File lib/fastlane_core/ui/implementations/shell.rb, line 61
def command_output(message)
  actual = (message.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) click to toggle source
# File lib/fastlane_core/ui/implementations/shell.rb, line 96
def confirm(message)
  verify_interactive!(message)
  agree("#{message} (y/n)".yellow, true)
end
deprecated(message) click to toggle source
# File lib/fastlane_core/ui/implementations/shell.rb, line 53
def deprecated(message)
  log.error(message.to_s.bold.blue)
end
error(message) click to toggle source

@!group Messaging: show text to the user

# File lib/fastlane_core/ui/implementations/shell.rb, line 37
def error(message)
  log.error(message.to_s.red)
end
header(message) click to toggle source
# File lib/fastlane_core/ui/implementations/shell.rb, line 73
def header(message)
  i = message.length + 8
  success("-" * i)
  success("--- " + message + " ---")
  success("-" * i)
end
important(message) click to toggle source
# File lib/fastlane_core/ui/implementations/shell.rb, line 41
def important(message)
  log.warn(message.to_s.yellow)
end
input(message) click to toggle source
# File lib/fastlane_core/ui/implementations/shell.rb, line 91
def input(message)
  verify_interactive!(message)
  ask(message.to_s.yellow).to_s.strip
end
interactive?() click to toggle source

@!group Errors: Inputs

# File lib/fastlane_core/ui/implementations/shell.rb, line 84
def interactive?
  interactive = true
  interactive = false if $stdout.isatty == false
  interactive = false if Helper.ci?
  return interactive
end
log() click to toggle source
# 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|
    if $verbose
      string = "#{severity} [#{datetime.strftime('%Y-%m-%d %H:%M:%S.%2N')}]: "
    elsif FastlaneCore::Env.truthy?("FASTLANE_HIDE_TIMESTAMP")
      string = ""
    else
      string = "[#{datetime.strftime('%H:%M:%S')}]: "
    end

    string += "#{msg}\n"

    string
  end

  @log
end
message(message) click to toggle source
# File lib/fastlane_core/ui/implementations/shell.rb, line 49
def message(message)
  log.info(message.to_s)
end
password(message) click to toggle source
# File lib/fastlane_core/ui/implementations/shell.rb, line 108
def password(message)
  verify_interactive!(message)

  ask(message.yellow) { |q| q.echo = "*" }
end
select(message, options) click to toggle source
# File lib/fastlane_core/ui/implementations/shell.rb, line 101
def select(message, options)
  verify_interactive!(message)

  important(message)
  choose(*options)
end
success(message) click to toggle source
# File lib/fastlane_core/ui/implementations/shell.rb, line 45
def success(message)
  log.info(message.to_s.green)
end
verbose(message) click to toggle source
# File lib/fastlane_core/ui/implementations/shell.rb, line 69
def verbose(message)
  log.debug(message.to_s) if $verbose
end

Private Instance Methods

verify_interactive!(message) click to toggle source
# File lib/fastlane_core/ui/implementations/shell.rb, line 116
def verify_interactive!(message)
  return if interactive?
  important(message)
  crash!("Could not retrieve response as fastlane runs in non-interactive mode")
end