--------------------------
Update to the maybeHelp() function in Maintenance.php, to tidy the way help output is displayed on the command-line:
* Only display the file name as part of the command, rather than the full path to it (when the path is long it was virtually unreadable).
* Wrap the option/parameter descriptions so that they sit neatly on the screen. Previously if a description ran to multiple lines it wrapped to column 1, possibly in the middle of a word. Now it wraps neatly and the subsequent lines are indented to make it clearer to read.
For now I have hard-coded the screen width to 80 characters, which is a sub-optimal solution. However I do not know how to get the current screen-width in a system-agnostic way, so I will leave that detail for some-one else to flesh out.
--------------------------
* @param $force boolean Whether to force the help to show, default false
*/
protected function maybeHelp( $force = false ) {
* @param $force boolean Whether to force the help to show, default false
*/
protected function maybeHelp( $force = false ) {
+ $screenWidth = 80; // TODO: Caculate this!
+ $tab = " ";
+ $descWidth = $screenWidth - ( 2 * strlen( $tab ) );
+
ksort( $this->mParams );
if( $this->hasOption( 'help' ) || $force ) {
$this->mQuiet = false;
ksort( $this->mParams );
if( $this->hasOption( 'help' ) || $force ) {
$this->mQuiet = false;
if( $this->mDescription ) {
$this->output( "\n" . $this->mDescription . "\n" );
}
if( $this->mDescription ) {
$this->output( "\n" . $this->mDescription . "\n" );
}
- $output = "\nUsage: php " . $this->mSelf;
+ $output = "\nUsage: php " . basename( $this->mSelf );
if( $this->mParams ) {
$output .= " [--" . implode( array_keys( $this->mParams ), "|--" ) . "]";
}
if( $this->mParams ) {
$output .= " [--" . implode( array_keys( $this->mParams ), "|--" ) . "]";
}
}
$this->output( "$output\n" );
foreach( $this->mParams as $par => $info ) {
}
$this->output( "$output\n" );
foreach( $this->mParams as $par => $info ) {
- $this->output( "\t$par : " . $info['desc'] . "\n" );
+ $this->output( wordwrap( "$tab$par : " . $info['desc'], $descWidth,
+ "\n$tab$tab" ) . "\n" );
}
foreach( $this->mArgList as $info ) {
}
foreach( $this->mArgList as $info ) {
- $this->output( "\t<" . $info['name'] . "> : " . $info['desc'] . "\n" );
+ $this->output( wordwrap( "$tab<" . $info['name'] . "> : " .
+ $info['desc'], $descWidth, "\n$tab$tab" ) . "\n" );