예제 #1
0
 function doReadline()
 {
     $keys = $this->conf->getAll();
     foreach ($keys as $key => $val) {
         $defs = $this->conf->getDefs($key);
         if (arr::hasKey($defs, 'vartype')) {
             $typeset = $defs['vartype'];
         } else {
             $typeset = typeof($val);
         }
         if (typeof($val) == 'array') {
             // Can't deal with these yet
         } else {
             printf(__astr("\\b{%s}: %s\n"), $key, $defs['description']);
             if (arr::hasKey($defs, 'extdescription')) {
                 printf(__astr('\\g{%s}'), $defs['extdescription']);
             }
             printf(__astr("  ["));
             switch ($typeset) {
                 case 'boolean':
                     if ($val) {
                         printf(__astr("\\c{ltcyan true}"));
                     } else {
                         printf(__astr("(\\c{cyan false})"));
                     }
                     break;
                 case 'NULL':
                     printf(__astr("\\c{red NULL}"));
                     break;
                 case 'integer':
                     printf(__astr("\\c{cyan %d}"), $val);
                     break;
                 case 'float':
                     printf(__astr("\\c{cyan %.2f}"), $val);
                     break;
                 default:
                     printf(__astr("\\c{yellow '%s'}"), $val);
             }
             printf(__astr("]: "));
             $rl = console::readline();
             if ($rl) {
                 $this->conf->{$key} = $rl;
                 printf("Updated value of %s\n", $key);
             }
             printf("\n");
         }
     }
     return true;
 }