dolibarr 21.0.0-alpha
functionscli.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2024 Laurent Destailleur <eldy@users.sourceforge.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 * or see https://www.gnu.org/
17 */
18
26// Define ANSI color constant to use colors and bold in CLI script
27define('DOL_COLOR_RESET', "\033[0m"); // Restore color
28define('DOL_COLOR_BOLD', "\033[1m"); // Bold
29define('DOL_COLOR_RED', "\033[31m");
30define('DOL_COLOR_GREEN', "\033[32m");
31define('DOL_COLOR_YELLOW', "\033[33m");
32define('DOL_COLOR_BLUE', "\033[34m");
33define('DOL_COLOR_MAGENTA', "\033[35m");
34define('DOL_COLOR_CYAN', "\033[36m");
35define('DOL_COLOR_WHITE', "\033[37m");
36
37
46function coloredText($text, $color, $bold = false)
47{
48 $boldCode = $bold ? DOL_COLOR_BOLD : '';
49 return $boldCode . $color . $text . DOL_COLOR_RESET;
50}
coloredText($text, $color, $bold=false)
Output text in color or bold.