Implement version command and better help

This commit is contained in:
Niklas Keller
2016-03-28 12:26:17 +02:00
parent 8d085347b9
commit 866b172c5f
5 changed files with 226 additions and 60 deletions

View File

@@ -218,4 +218,26 @@ function getBinary() {
}
return $binary;
}
/**
* Cuts a text to a certain length and appends an ellipsis if necessary.
*
* @param string $text text to shorten
* @param int $max maximum length
* @param string $append appendix when too long
* @return string shortened string
*/
function ellipsis($text, $max = 70, $append = "") {
if (strlen($text) <= $max) {
return $text;
}
$out = substr($text, 0, $max);
if (strpos($text, " ") === false) {
return $out . $append;
}
return preg_replace("/\\w+$/", "", $out) . $append;
}