コード例 #1
0
ファイル: Response.php プロジェクト: php-yaoi/php-yaoi
 /**
  * @param mixed $message
  * @return $this
  */
 public function addContent($message)
 {
     if ($message instanceof Progress) {
         if ($this->console->attached()) {
             if ($this->progressStartedLength) {
                 $this->console->returnCaret();
             }
             $text = round(100 * $message->done / $message->total) . '%, ' . $message->done . '/' . $message->total . ' ' . $message->text;
             if (strlen($text) < $this->progressStartedLength) {
                 $text = str_pad($text, $this->progressStartedLength, ' ');
             } else {
                 $this->progressStartedLength = strlen($text);
             }
             $this->console->printF($text);
         }
         return $this;
     }
     if ($this->progressStartedLength) {
         $this->progressStartedLength = 0;
         $this->console->eol();
     }
     if ($message instanceof SubContent) {
         $this->console->setPadding('   ');
         $this->addContent($message->content);
         $this->console->setPadding('');
         return $this;
     }
     if ($message instanceof Rows) {
         $message = (string) Table::create($message->getIterator())->setShowHeader();
     } elseif ($message instanceof Text) {
         $message = new ViewText($message);
     }
     $this->console->printLines($message);
     return $this;
 }
コード例 #2
0
ファイル: Runner.php プロジェクト: php-yaoi/php-yaoi
 public function showHelp()
 {
     $this->showVersion();
     try {
         $def = new PrepareDefinition($this->optionsArray);
     } catch (Exception $exception) {
         $this->response->error('Command definition error: ' . $exception->getMessage());
         return;
     }
     $def->initOptions();
     $this->response->addContent(new Heading('Usage: '));
     $this->response->addContent(new SubContent($this->commandName . $def->usage));
     if ($def->argumentsDescription) {
         $this->response->addContent(new SubContent(Table::create(new \ArrayIterator($def->argumentsDescription))));
     }
     if ($def->optionsDescription) {
         foreach ($def->optionsDescription as $group => $descriptions) {
             $this->response->addContent(new Heading($group . ": "));
             $this->response->addContent(new SubContent(Table::create(new \ArrayIterator($descriptions))));
         }
     }
 }