overflow in css instead of wrap="virtual"
[mediawiki.git] / maintenance / mcc.php
blob66fe6664a98b2de3277e1d75d2f7482ba5886bd3
1 <?php
2 include_once( "../includes/DefaultSettings.php" );
3 include_once( "../LocalSettings.php" );
4 include_once( "../includes/MemCachedClient.inc.php" );
6 $mcc = new MemCachedClient();
7 $mcc->set_servers( $wgMemCachedServers );
9 do {
10 $bad = false;
11 $quit = false;
12 $line = readconsole( "> " );
13 $args = explode( " ", $line );
14 $command = array_shift( $args );
15 switch ( $command ) {
16 case "get":
17 print "Getting {$args[0]}[{$args[1]}]\n";
18 $res = $mcc->get( $args[0] );
19 if ( array_key_exists( 1, $args ) ) {
20 $res = $res[$args[1]];
22 if ( $res === false ) {
23 print 'Error: ' . $mcc->error_string() . "\n";
24 } elseif ( is_string( $res ) ) {
25 print "$res\n";
26 } else {
27 var_dump( $res );
29 break;
30 case "set":
31 $key = array_shift( $args );
32 if ( $args[0] == "#" && is_numeric( $args[1] ) ) {
33 $value = str_repeat( "*", $args[1] );
34 } else {
35 $value = implode( " ", $args );
37 if ( !$mcc->set( $key, $value, 0 ) ) {
38 print 'Error: ' . $mcc->error_string() . "\n";
40 break;
41 case "delete":
42 $key = implode( " ", $args );
43 if ( !$mcc->delete( $key ) ) {
44 print 'Error: ' . $mcc->error_string() . "\n";
46 break;
47 case "quit":
48 $quit = true;
49 break;
50 default:
51 $bad = true;
53 if ( $bad ) {
54 if ( $command ) {
55 print "Bad command\n";
57 } else {
58 if ( function_exists( "readline_add_history" ) ) {
59 readline_add_history( $line );
62 } while ( !$quit );
64 function readconsole( $prompt = "" ) {
65 if ( function_exists( "readline" ) ) {
66 return readline( $prompt );
67 } else {
68 print $prompt;
69 $fp = fopen( "php://stdin", "r" );
70 $resp = trim( fgets( $fp, 1024 ) );
71 fclose( $fp );
72 return $resp;