Beispiel #1
0
 /**
  *
  */
 public function testClean()
 {
     $tab = new SimpleTable();
     $tab->border = true;
     $tab->padding = 0;
     $tab->addRow(array('1', 'one'));
     $tab->clean();
     $tab->addRow(array('2', 'two'));
     $tab->addRow(array('3', 'three'));
     $expected = array('+-+-----+', '|2|two  |', '|3|three|', '+-+-----+');
     $this->assertEquals($expected, $tab->getTable(true));
 }
Beispiel #2
0
 /**
  * Show the help message.
  *
  * @param Parameters $params
  *
  * @return void
  */
 protected function showHelp(Parameters $params)
 {
     $table = new SimpleTable();
     $table->border = false;
     $table->padding = 3;
     $executedFile = basename($params->getExecutedFile());
     $arguments = $params->getRegisteredArguments();
     $argsUsage = '';
     $argsRows = [];
     foreach ($arguments as $arg) {
         $argsUsage .= ' <' . $arg['name'] . '>';
         $argsRows[] = [$arg['name'], $arg['description']];
     }
     $this->outln('Usage: ' . $executedFile . $argsUsage);
     // show possible arguments
     if ($argsRows) {
         $table->addRow([]);
         $table->addRow(['Arguments:']);
         foreach ($argsRows as $row) {
             $table->addRow($row);
         }
     }
     // show possible options
     $options = $params->getRegisteredOptions();
     if ($options) {
         $table->addRow([]);
         $table->addRow(['Options:']);
         foreach ($options as $opt) {
             $val = '';
             switch ($opt['valueFlag']) {
                 case Parameters::VALUE_YES:
                     $val = '=<value>';
                     break;
                 case Parameters::VALUE_OPTIONAL:
                     $val = '[=<value>]';
                     break;
             }
             $def = '--' . $opt['name'] . $val;
             if ($opt['short']) {
                 $def .= ' -' . $opt['short'] . $val;
             }
             $table->addRow([$def, $opt['description']]);
         }
     }
     $this->outln($table->getTable());
 }