Method: CLI::UI.resolve_text

Defined in:
lib/cli/ui.rb

.resolve_text(input, truncate_to: nil, enable_color: enable_color?) ) ⇒ Object

Convenience Method to resolve text using CLI::UI::Formatter.format Check CLI::UI::Formatter::SGR_MAP for available formatting options

Attributes

  • input - input to format

  • truncate_to - number of characters to truncate the string to (or nil)

  • enable_color - should color be used? default to true unless output is redirected.

: (String input, ?truncate_to: Integer?, ?enable_color: bool) -> String



134
135
136
137
138
139
# File 'lib/cli/ui.rb', line 134

def resolve_text(input, truncate_to: nil, enable_color: enable_color?)
  formatted = CLI::UI::Formatter.new(input).format(enable_color: enable_color)
  return formatted unless truncate_to

  CLI::UI::Truncater.call(formatted, truncate_to)
end