r63734 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63733‎ | r63734 | r63735 >
Date:11:38, 14 March 2010
Author:happydog
Status:ok
Tags:
Comment:
Porting my update to the maybeHelp() function in Maintenance.php into the trunk. This was accidentally committed to the 1.16 branch (rather than trunk, as intended) in r62955. Here is the original commit message:

--------------------------
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.
--------------------------
Modified paths:
  • /trunk/phase3/maintenance/Maintenance.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/Maintenance.php
@@ -565,6 +565,10 @@
566566 * @param $force boolean Whether to force the help to show, default false
567567 */
568568 protected function maybeHelp( $force = false ) {
 569+ $screenWidth = 80; // TODO: Caculate this!
 570+ $tab = " ";
 571+ $descWidth = $screenWidth - ( 2 * strlen( $tab ) );
 572+
569573 ksort( $this->mParams );
570574 if( $this->hasOption( 'help' ) || $force ) {
571575 $this->mQuiet = false;
@@ -572,7 +576,7 @@
573577 if( $this->mDescription ) {
574578 $this->output( "\n" . $this->mDescription . "\n" );
575579 }
576 - $output = "\nUsage: php " . $this->mSelf;
 580+ $output = "\nUsage: php " . basename( $this->mSelf );
577581 if( $this->mParams ) {
578582 $output .= " [--" . implode( array_keys( $this->mParams ), "|--" ) . "]";
579583 }
@@ -586,10 +590,12 @@
587591 }
588592 $this->output( "$output\n" );
589593 foreach( $this->mParams as $par => $info ) {
590 - $this->output( "\t$par : " . $info['desc'] . "\n" );
 594+ $this->output( wordwrap( "$tab$par : " . $info['desc'], $descWidth,
 595+ "\n$tab$tab" ) . "\n" );
591596 }
592597 foreach( $this->mArgList as $info ) {
593 - $this->output( "\t<" . $info['name'] . "> : " . $info['desc'] . "\n" );
 598+ $this->output( wordwrap( "$tab<" . $info['name'] . "> : " .
 599+ $info['desc'], $descWidth, "\n$tab$tab" ) . "\n" );
594600 }
595601 die( 1 );
596602 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r63735Fixing up r62955 - changing tabs to spaces, as suggested by NikeRabbit (http:...happydog11:45, 14 March 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r62955Update to the maybeHelp() function in Maintenance.php, to tidy the way help o...happydog11:56, 25 February 2010

Status & tagging log