From: Marcus Boerger Date: Fri, 11 May 2007 21:28:41 +0000 (+0000) Subject: - Provide working wordwrap for command help X-Git-Tag: RELEASE_1_2_0~86 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=68672e40036e53c3db8d3c722cb51dc41a8561f2;p=php - Provide working wordwrap for command help --- diff --git a/ext/phar/phar/clicommand.inc b/ext/phar/phar/clicommand.inc index c6b56f4eb8..59982ffe41 100755 --- a/ext/phar/phar/clicommand.inc +++ b/ext/phar/phar/clicommand.inc @@ -234,11 +234,18 @@ abstract class CLICommand { return "This help."; } + + private function cli_wordwrap($what, $l, $sp) + { + $l = max(80 - $l, 40); // minimum length + $what = str_replace("\n", "\n".$sp, $what); + return wordwrap($what, $l, "\n".$sp); + } - private function cli_help_get_args($args, $l, $sp, $required) + private function cli_help_get_args($func, $l, $sp, $required) { $inf = ""; - foreach(call_user_func(array($this, $args)) as $arg => $conf) + foreach(call_user_func($func, $l, $sp) as $arg => $conf) { if ((isset($conf['required']) && $conf['required']) != $required) { @@ -303,13 +310,13 @@ Commands: $inf = $name . substr($sp, strlen($name)); if (isset($funcs['inf'])) { - $inf .= call_user_func(array($this, $funcs['inf'])) . "\n"; + $inf .= $this->cli_wordwrap(call_user_func(array($this, $funcs['inf'])), $l, $sp) . "\n"; if (isset($funcs['arg'])) { $inf .= "\n"; - $inf .= $this->cli_help_get_args($funcs['arg'], $l, $sp, true); + $inf .= $this->cli_help_get_args(array($this, $funcs['arg']), $l, $sp, true); $inf .= "\n"; - $inf .= $this->cli_help_get_args($funcs['arg'], $l, $sp, false); + $inf .= $this->cli_help_get_args(array($this, $funcs['arg']), $l, $sp, false); } } echo "$inf\n\n";