Commit 05e55074 authored by Fabio Pelosin's avatar Fabio Pelosin

[UI] Use CLAide for wrapping

Closes https://github.com/CocoaPods/CocoaPods/issues/2333
parent 2b3d0532
...@@ -119,7 +119,7 @@ module Pod ...@@ -119,7 +119,7 @@ module Pod
# #
def info(message) def info(message)
indentation = config.verbose? ? self.indentation_level : 0 indentation = config.verbose? ? self.indentation_level : 0
indented = wrap_string(message, ' ' * indentation) indented = wrap_string(message, indentation)
puts(indented) puts(indented)
self.indentation_level += 2 self.indentation_level += 2
...@@ -209,7 +209,7 @@ module Pod ...@@ -209,7 +209,7 @@ module Pod
# wrapping it to the terminal width if necessary. # wrapping it to the terminal width if necessary.
# #
def puts_indented(message = '') def puts_indented(message = '')
indented = wrap_string(message, ' ' * self.indentation_level) indented = wrap_string(message, self.indentation_level)
puts(indented) puts(indented)
end end
...@@ -224,8 +224,9 @@ module Pod ...@@ -224,8 +224,9 @@ module Pod
next if warning[:verbose_only] && !config.verbose? next if warning[:verbose_only] && !config.verbose?
STDERR.puts("\n[!] #{warning[:message]}".yellow) STDERR.puts("\n[!] #{warning[:message]}".yellow)
warning[:actions].each do |action| warning[:actions].each do |action|
indented = wrap_string(action, ' - ') string = "- #{action}"
puts(indented) string = wrap_string(string, 4)
puts(string)
end end
end end
end end
...@@ -283,13 +284,13 @@ module Pod ...@@ -283,13 +284,13 @@ module Pod
# @note If CocoaPods is not being run in a terminal or the width of the # @note If CocoaPods is not being run in a terminal or the width of the
# terminal is too small a width of 80 is assumed. # terminal is too small a width of 80 is assumed.
# #
def wrap_string(txt, indent = '') def wrap_string(string, indent = 0)
if disable_wrap || !STDIN.tty? if disable_wrap
txt string
else else
width = `stty size`.split(' ')[1].to_i - indent.length first_space = ' ' * indent
width = 80 unless width >= 10 indented = CLAide::Helper.wrap_with_indent(string, indent, 9999)
txt.strip.gsub(/(.{1,#{width}})( +|$)\n?|(.{#{width}})/, indent + "\\1\\3\n") first_space + indented
end end
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment