Puppet Function: wmflib::ansi::bg

Defined in:
modules/wmflib/functions/ansi/bg.pp
Function type:
Puppet Language

Summary

function to change the background colour of text

Overview

wmflib::ansi::bg(String[1] $text, Wmflib::Ansi::Colour $colour, Boolean $reset = true)String

SPDX-License-Identifier: Apache-2.0

Parameters:

  • text (String[1])

    the text to wrap

  • colour (Wmflib::Ansi::Colour)

    the colour to use

  • reset (Boolean) (defaults to: true)

    if true terminate text with the reset string

Returns:



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'modules/wmflib/functions/ansi/bg.pp', line 6

function wmflib::ansi::bg (
    String[1]            $text,
    Wmflib::Ansi::Colour $colour,
    Boolean              $reset = true
) >> String {
    $csi = "\u001B[" # lint:ignore:double_quoted_strings
    $colour_codes = {
        'black'   => 40,
        'red'     => 41,
        'green'   => 42,
        'yellow'  => 43,
        'blue'    => 44,
        'magenta' => 45,
        'cyan'    => 46,
        'white'   => 47,
    }
    $formated =  "${csi}${colour_codes[$colour]}m${text}"
    $reset.bool2str(wmflib::ansi::reset($formated), $formated)
}