r61374 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61373‎ | r61374 | r61375 >
Date:18:04, 22 January 2010
Author:demon
Status:ok
Tags:
Comment:
Cleanup needless code duplication
Modified paths:
  • /trunk/phase3/maintenance/mcc.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/mcc.php
@@ -15,58 +15,30 @@
1616 #$mcc->set_debug( true );
1717
1818 function mccShowHelp($command) {
19 -
20 - if(! $command ) { $command = 'fullhelp'; }
21 - $onlyone = true;
22 -
23 - switch ( $command ) {
24 -
25 - case 'fullhelp':
26 - // will show help for all commands
27 - $onlyone = false;
28 -
29 - case 'get':
30 - print "get: grabs something\n";
31 - if($onlyone) { break; }
32 -
33 - case 'getsock':
34 - print "getsock: lists sockets\n";
35 - if($onlyone) { break; }
36 -
37 - case 'set':
38 - print "set: changes something\n";
39 - if($onlyone) { break; }
40 -
41 - case 'delete':
42 - print "delete: deletes something\n";
43 - if($onlyone) { break; }
44 -
45 - case 'history':
46 - print "history: show command line history\n";
47 - if($onlyone) { break; }
48 -
49 - case 'server':
50 - print "server: show current memcached server\n";
51 - if($onlyone) { break; }
52 -
53 - case 'dumpmcc':
54 - print "dumpmcc: shows the whole thing\n";
55 - if($onlyone) { break; }
56 -
57 - case 'exit':
58 - case 'quit':
59 - print "exit or quit: exit mcc\n";
60 - if($onlyone) { break; }
61 -
62 - case 'help':
63 - print "help: help about a command\n";
64 - if($onlyone) { break; }
65 -
66 - default:
67 - if($onlyone) {
68 - print "$command: command does not exist or no help for it\n";
69 - }
 19+ $commandList = array(
 20+ 'get' => 'grabs something',
 21+ 'getsock' => 'lists sockets',
 22+ 'set' => 'changes something',
 23+ 'delete' => 'deletes something',
 24+ 'history' => 'show command line history',
 25+ 'server' => 'show current memcached server',
 26+ 'dumpmcc' => 'shows the whole thing',
 27+ 'exit' => 'exit mcc',
 28+ 'quit' => 'exit mcc',
 29+ 'help' => 'help about a command',
 30+ );
 31+ if( !$command ) {
 32+ $command = 'fullhelp';
7033 }
 34+ if( $command === 'fullhelp' ) {
 35+ foreach( $commandList as $cmd => $desc ) {
 36+ print "$cmd: $desc\n";
 37+ }
 38+ } elseif( isset( $commandList[$command] ) ) {
 39+ print "$cmd: $desc\n";
 40+ } else {
 41+ print "$command: command does not exist or no help for it\n";
 42+ }
7143 }
7244
7345 do {
@@ -176,5 +148,3 @@
177149 }
178150 }
179151 } while ( !$quit );
180 -
181 -

Status & tagging log