Puppet Function: wmflib::ansi::attr
- Defined in:
- modules/wmflib/functions/ansi/attr.pp
- Function type:
- Puppet Language
Summary
function to wrap a string in ansi colour formatingOverview
SPDX-License-Identifier: Apache-2.0
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'modules/wmflib/functions/ansi/attr.pp', line 6
function wmflib::ansi::attr (
String[1] $text,
Wmflib::Ansi::Formating $format,
Boolean $reset = true
) >> String {
$csi = "\u001B[" # lint:ignore:double_quoted_strings
$format_codes = {
'normal' => 0,
'bold' => 1,
'underlined' => 4,
'blinking' => 5,
'reverse' => 7,
}
$formated = "${csi}${format_codes[$format]}m${text}"
$reset.bool2str(wmflib::ansi::reset($formated), $formated)
}
|