r76621 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76620‎ | r76621 | r76622 >
Date:10:33, 13 November 2010
Author:hashar
Status:ok (Comments)
Tags:
Comment:
justify help memcached console help
Modified paths:
  • /trunk/phase3/maintenance/mcc.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/mcc.php
@@ -31,8 +31,12 @@
3232 $command = 'fullhelp';
3333 }
3434 if ( $command === 'fullhelp' ) {
 35+ $max_cmd_len = 0;
 36+ foreach( array_keys( $commandList ) as $cmd ) {
 37+ $max_cmd_len = max( $max_cmd_len, strlen($cmd) );
 38+ }
3539 foreach ( $commandList as $cmd => $desc ) {
36 - print "$cmd: $desc\n";
 40+ printf( "%-{$max_cmd_len}s: %s\n", $cmd, $desc );
3741 }
3842 } elseif ( isset( $commandList[$command] ) ) {
3943 print "$command: $commandList[$command]\n";

Follow-up revisions

RevisionCommit summaryAuthorDate
r77712Max command length using one line of code...hashar08:58, 4 December 2010

Comments

#Comment by Catrope (talk | contribs)   22:48, 2 December 2010

Just FYI: you can get the max length with a one-liner if you like with $maxlen = max( array_map( 'strlen', array_keys( $commandList ) ) );

#Comment by Hashar (talk | contribs)   00:42, 7 December 2010

Oneliner applied in r77712

I like perl "map", but somehow, I never managed to use PHP array_map().

Status & tagging log