Class: FastlaneCore::Shell
- Inherits:
-
Interface
show all
- Defined in:
- fastlane_core/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
Instance Method Summary
collapse
Methods inherited from Interface
#abort_with_message!, #build_failure!, #crash!, #not_implemented, #shell_error!, #test_failure!, #to_s, #user_error!
Instance Method Details
#command(message) ⇒ Object
66
67
68
|
# File 'fastlane_core/lib/fastlane_core/ui/implementations/shell.rb', line 66
def command(message)
log.info("$ #{message}".cyan)
end
|
#command_output(message) ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
|
# File 'fastlane_core/lib/fastlane_core/ui/implementations/shell.rb', line 70
def command_output(message)
actual = (message.split("\r").last || "") actual.split("\n").each do |msg|
if FastlaneCore::Env.truthy?("FASTLANE_DISABLE_OUTPUT_FORMAT")
log.info(msg)
else
prefix = msg.include?("▸") ? "" : "▸ "
log.info(prefix + "" + msg.magenta)
end
end
end
|
#confirm(message) ⇒ Object
115
116
117
118
|
# File 'fastlane_core/lib/fastlane_core/ui/implementations/shell.rb', line 115
def confirm(message)
verify_interactive!(message)
agree("#{format_string}#{message.to_s.yellow} (y/n)", true)
end
|
#deprecated(message) ⇒ Object
62
63
64
|
# File 'fastlane_core/lib/fastlane_core/ui/implementations/shell.rb', line 62
def deprecated(message)
log.error(message.to_s.deprecated)
end
|
#error(message) ⇒ Object
46
47
48
|
# File 'fastlane_core/lib/fastlane_core/ui/implementations/shell.rb', line 46
def error(message)
log.error(message.to_s.red)
end
|
32
33
34
35
36
37
38
39
40
|
# File 'fastlane_core/lib/fastlane_core/ui/implementations/shell.rb', line 32
def format_string(datetime = Time.now, severity = "")
if FastlaneCore::Globals.verbose?
return "#{severity} [#{datetime.strftime('%Y-%m-%d %H:%M:%S.%2N')}]: "
elsif FastlaneCore::Env.truthy?("FASTLANE_HIDE_TIMESTAMP")
return ""
else
return "[#{datetime.strftime('%H:%M:%S')}]: "
end
end
|
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'fastlane_core/lib/fastlane_core/ui/implementations/shell.rb', line 86
def (message)
format = format_string
if message.length + 8 < TTY::Screen.width - format.length
message = "--- #{message} ---"
i = message.length
else
i = TTY::Screen.width - format.length
end
success("-" * i)
success(message)
success("-" * i)
end
|
#important(message) ⇒ Object
50
51
52
|
# File 'fastlane_core/lib/fastlane_core/ui/implementations/shell.rb', line 50
def important(message)
log.warn(message.to_s.yellow)
end
|
110
111
112
113
|
# File 'fastlane_core/lib/fastlane_core/ui/implementations/shell.rb', line 110
def input(message)
verify_interactive!(message)
ask("#{format_string}#{message.to_s.yellow}").to_s.strip
end
|
#interactive? ⇒ Boolean
103
104
105
106
107
108
|
# File 'fastlane_core/lib/fastlane_core/ui/implementations/shell.rb', line 103
def interactive?
interactive = true
interactive = false if $stdout.isatty == false
interactive = false if Helper.ci?
return interactive
end
|
#log ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'fastlane_core/lib/fastlane_core/ui/implementations/shell.rb', line 13
def log
return @log if @log
$stdout.sync = true
if Helper.test? && !ENV.key?('DEBUG')
$stdout.puts("Logging disabled while running tests. Force them by setting the DEBUG environment variable")
@log ||= Logger.new(nil) else
@log ||= Logger.new($stdout)
end
@log.formatter = proc do |severity, datetime, progname, msg|
"#{format_string(datetime, severity)}#{msg}\n"
end
@log
end
|
#message(message) ⇒ Object
58
59
60
|
# File 'fastlane_core/lib/fastlane_core/ui/implementations/shell.rb', line 58
def message(message)
log.info(message.to_s)
end
|
#password(message) ⇒ Object
127
128
129
130
131
|
# File 'fastlane_core/lib/fastlane_core/ui/implementations/shell.rb', line 127
def password(message)
verify_interactive!(message)
ask("#{format_string}#{message.to_s.yellow}") { |q| q.echo = "*" }
end
|
#select(message, options) ⇒ Object
120
121
122
123
124
125
|
# File 'fastlane_core/lib/fastlane_core/ui/implementations/shell.rb', line 120
def select(message, options)
verify_interactive!(message)
important(message)
choose(*options)
end
|
#success(message) ⇒ Object
54
55
56
|
# File 'fastlane_core/lib/fastlane_core/ui/implementations/shell.rb', line 54
def success(message)
log.info(message.to_s.green)
end
|
#verbose(message) ⇒ Object
82
83
84
|
# File 'fastlane_core/lib/fastlane_core/ui/implementations/shell.rb', line 82
def verbose(message)
log.debug(message.to_s) if FastlaneCore::Globals.verbose?
end
|