Skip to content

Commit

Permalink
Add quiet parameter to hide output
Browse files Browse the repository at this point in the history
  • Loading branch information
Takika authored Jan 3, 2025
1 parent 53b1e7b commit c379459
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions bin/updatecss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/');
require_once INSTALL_PATH . 'program/include/clisetup.php';

// get arguments
$opts = rcube_utils::get_opt(['d' => 'dir']);
$opts = rcube_utils::get_opt(['d' => 'dir', 'q' => 'quiet:bool']);

if (empty($opts['dir'])) {
echo "Skin directory not specified (--dir). Using skins/ and plugins/*/skins/.\n";
Expand All @@ -42,6 +42,8 @@ elseif (!file_exists($opts['dir'])) {
$dirs = [$opts['dir']];
}

$quiet = !empty($opts['quiet']);

foreach ($dirs as $dir) {
$img_dir = $dir . '/images';
if (!file_exists($img_dir)) {
Expand All @@ -62,7 +64,9 @@ foreach ($dirs as $dir) {

foreach ($files as $file) {
$file = $dir . '/' . $file;
echo "File: {$file}\n";
if (!$quiet) {
echo "File: {$file}\n";
}
$content = file_get_contents($file);
$content = preg_replace($find, $replace, $content, -1, $count);
if ($count) {
Expand All @@ -73,14 +77,18 @@ foreach ($dirs as $dir) {

function get_images($dir)
{
global $quiet;

$images = [];
$dh = opendir($dir);

while ($file = readdir($dh)) {
if (preg_match('/^(.+)\.(gif|ico|png|jpg|jpeg)$/', $file, $m)) {
$filepath = "{$dir}/{$file}";
$images[$file] = substr(md5_file($filepath), 0, 4) . '.' . filesize($filepath);
echo "Image: {$filepath} ({$images[$file]})\n";
if (!$quiet) {
echo "Image: {$filepath} ({$images[$file]})\n";
}
} elseif ($file != '.' && $file != '..' && is_dir($dir . '/' . $file)) {
foreach (get_images($dir . '/' . $file) as $img => $sum) {
$images[$file . '/' . $img] = $sum;
Expand Down

0 comments on commit c379459

Please sign in to comment.