0.7.2
This commit is contained in:
@@ -1,6 +1,41 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
// Classes
|
||||
//////////////////////////////////////////
|
||||
|
||||
class ProgressBar {
|
||||
|
||||
protected static $done = 0;
|
||||
protected static $total = 0;
|
||||
|
||||
public static function display($message = null) {
|
||||
$string = "PROGRESS:".round((self::$done/self::$total)*100,2);
|
||||
if ($message) {
|
||||
return "\t".$string."\n".$message;
|
||||
} elseif (!strpos(__FILE__,".app")) {
|
||||
return "\r\033[K\r".$string;
|
||||
} else {
|
||||
return "\n".$string;
|
||||
}
|
||||
}
|
||||
|
||||
public static function start($total, $message = null) {
|
||||
self::$total = $total;
|
||||
return $message."\n".self::display();
|
||||
}
|
||||
|
||||
public static function next($message = null) {
|
||||
self::$done++;
|
||||
return self::display($message);
|
||||
}
|
||||
|
||||
public static function finish() {
|
||||
self::$done = 0;
|
||||
return "\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Functions
|
||||
//////////////////////////////////////////
|
||||
|
||||
@@ -18,12 +53,8 @@ function getParents($zpath, $pathname) {
|
||||
function stringPrint($string) {
|
||||
echo $string.@str_repeat(" ", (10-strlen($string)));
|
||||
}
|
||||
|
||||
function bashcolor($string, $color) {
|
||||
echo $string;
|
||||
}
|
||||
|
||||
function shortlabel($pathname, $max, $min = null) {
|
||||
function shortlabel($pathname, $max = 99, $pad = false) {
|
||||
$basename = basename($pathname);
|
||||
$suffix = "(...).".pathinfo($basename,PATHINFO_EXTENSION);
|
||||
if (strlen($basename) > $max) {
|
||||
@@ -31,12 +62,10 @@ function shortlabel($pathname, $max, $min = null) {
|
||||
} else {
|
||||
$return = $basename;
|
||||
}
|
||||
if (strlen($return) < $min) {
|
||||
$out = $return.@str_repeat(" ", ($min-strlen($return)));
|
||||
} else {
|
||||
$out = $return;
|
||||
if ($pad) {
|
||||
$return = $return.@str_repeat(" ", ($max-strlen($return)));
|
||||
}
|
||||
return $out;
|
||||
return $return;
|
||||
}
|
||||
|
||||
function human_filesize($bytes, $decimals = 2) {
|
||||
|
||||
Reference in New Issue
Block a user