Skip to content

Commit

Permalink
MDL-50631 cli: Add a new function to display Moodle ASCII logo
Browse files Browse the repository at this point in the history
  • Loading branch information
mudrd8mz committed Jun 17, 2015
1 parent f1a415e commit 85f8fe5
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions lib/clilib.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,35 @@ function cli_error($text, $errorcode=1) {
die($errorcode);
}

/**
* Print an ASCII version of the Moodle logo.
*
* @param int $padding left padding of the logo
* @param bool $return should we print directly (false) or return the string (true)
* @return mixed void or string
*/
function cli_logo($padding=2, $return=false) {

$lines = array(
' .-..-. ',
' _____ | || | ',
'/____/-.---_ .---. .---. .-.| || | .---. ',
'| | _ _ |/ _ \\/ _ \\/ _ || |/ __ \\',
'* | | | | | || |_| || |_| || |_| || || |___/',
' |_| |_| |_|\\_____/\\_____/\\_____||_|\\_____)',
);

$logo = '';

foreach ($lines as $line) {
$logo .= str_repeat(' ', $padding);
$logo .= $line;
$logo .= PHP_EOL;
}

if ($return) {
return $logo;
} else {
echo $logo;
}
}

0 comments on commit 85f8fe5

Please sign in to comment.