Index: trunk/phase3/maintenance/mcc.php |
— | — | @@ -15,8 +15,56 @@ |
16 | 16 | $mcc->set_servers( $wgMemCachedServers ); |
17 | 17 | $mcc->set_debug( true ); |
18 | 18 | |
| 19 | +function mccShowHelp($command) { |
| 20 | + |
| 21 | + if(! $command ) { $command = 'fullhelp'; } |
| 22 | + $onlyone = true; |
| 23 | + |
| 24 | + switch ( $command ) { |
| 25 | + |
| 26 | + case 'fullhelp': |
| 27 | + // will show help for all commands |
| 28 | + $onlyone = false; |
| 29 | + |
| 30 | + case 'get': |
| 31 | + print "get: grabs something\n"; |
| 32 | + if($onlyone) { break; } |
| 33 | + |
| 34 | + case 'getsock': |
| 35 | + print "getsock: lists sockets\n"; |
| 36 | + if($onlyone) { break; } |
| 37 | + |
| 38 | + case 'set': |
| 39 | + print "set: changes something\n"; |
| 40 | + if($onlyone) { break; } |
| 41 | + |
| 42 | + case 'delete': |
| 43 | + print "delete: deletes something\n"; |
| 44 | + if($onlyone) { break; } |
| 45 | + |
| 46 | + case 'dumpmcc': |
| 47 | + print "dumpmcc: shows the whole thing\n"; |
| 48 | + if($onlyone) { break; } |
| 49 | + |
| 50 | + case 'exit': |
| 51 | + case 'quit': |
| 52 | + print "exit or quit: exit mcc\n"; |
| 53 | + if($onlyone) { break; } |
| 54 | + |
| 55 | + case 'help': |
| 56 | + print "help: help about a command\n"; |
| 57 | + if($onlyone) { break; } |
| 58 | + |
| 59 | + default: |
| 60 | + if($onlyone) { |
| 61 | + print "$command: command does not exist or no help for it\n"; |
| 62 | + } |
| 63 | + } |
| 64 | +} |
| 65 | + |
19 | 66 | do { |
20 | 67 | $bad = false; |
| 68 | + $showhelp = false; |
21 | 69 | $quit = false; |
22 | 70 | |
23 | 71 | $line = readconsole( '> ' ); |
— | — | @@ -25,7 +73,12 @@ |
26 | 74 | $args = explode( ' ', $line ); |
27 | 75 | $command = array_shift( $args ); |
28 | 76 | |
| 77 | + // process command |
29 | 78 | switch ( $command ) { |
| 79 | + case 'help': |
| 80 | + // show an help message |
| 81 | + mccShowHelp(array_shift($args)); |
| 82 | + break; |
30 | 83 | |
31 | 84 | case 'get': |
32 | 85 | print "Getting {$args[0]}[{$args[1]}]\n"; |
— | — | @@ -41,7 +94,7 @@ |
42 | 95 | } else { |
43 | 96 | var_dump( $res ); |
44 | 97 | } |
45 | | - break; |
| 98 | + break; |
46 | 99 | |
47 | 100 | case 'getsock': |
48 | 101 | $res = $mcc->get( $args[0] ); |
— | — | @@ -81,7 +134,8 @@ |
82 | 135 | |
83 | 136 | default: |
84 | 137 | $bad = true; |
85 | | - } |
| 138 | + } // switch() end |
| 139 | + |
86 | 140 | if ( $bad ) { |
87 | 141 | if ( $command ) { |
88 | 142 | print "Bad command\n"; |