Esempio n. 1
0
 /**
  * Counts down from n.
  *
  * @access  public
  * @param   int     $from  Number of seconds to count down
  */
 public function draw($from = 5)
 {
     $dots = 0;
     $fromLength = strlen($from);
     $totalLength = $fromLength + 5;
     do {
         do {
             $numbers = str_pad($from, $fromLength, '0', STR_PAD_LEFT);
             $this->output->write("\r" . str_pad($numbers . ' ' . str_repeat('.', $dots) . ' ', $totalLength, ' '));
             usleep(250000);
         } while ($dots++ < 3);
         $dots = 0;
     } while ($from-- > 1);
     $this->output->write("\r" . str_repeat(' ', $totalLength) . "\r");
 }
Esempio n. 2
0
 /**
  * Run the reactor.
  *
  * @access  public
  */
 public function run()
 {
     $this->handleCustomOptions();
     $this->output->write(PHP_EOL);
     if (($command = $this->input->getArgument(1)) === null) {
         $this->displayReactorInfo();
         $this->listCommands();
     } else {
         $this->dispatch($command);
     }
     $this->output->write(PHP_EOL);
 }
Esempio n. 3
0
 /**
  * Draws the progressbar.
  *
  * @access  public
  */
 public function draw()
 {
     // Don't draw progess bar if there are 0 items
     if ($this->items === 0) {
         return;
     }
     // Calculate percent
     $percent = (int) ceil(min($this->progress / $this->items * 100, 100));
     // Build progress bar
     $progressBar = $this->buildProgressBar($percent);
     // Draw progressbar
     $this->output->write("\r" . $progressBar);
     // If we're done then we'll add a newline to the output
     if ($this->progress === $this->items) {
         $this->output->write(PHP_EOL);
     }
 }
Esempio n. 4
0
 /**
  * Draws a table.
  *
  * @access  public
  * @param   array   $columnNames  Array of column names
  * @param   array   $rows         Array of rows
  * @param   int     $writer       Output writer
  */
 public function draw(array $columnNames, array $rows, $writer = Output::STANDARD)
 {
     $this->output->write($this->render($columnNames, $rows), $writer);
 }
Esempio n. 5
0
 /**
  * Retruns a generic error.
  *
  * @access  protected
  * @return  string
  */
 protected function getGenericError()
 {
     $this->output->errorLn('<bg_red><white>An error has occurred while processing your task.</white></bg_red>' . PHP_EOL);
 }
Esempio n. 6
0
 /**
  * Rings the terminal bell n times.
  *
  * @access  public
  * @param   int     $times  Number of times to ring the bell
  */
 public function ring($times = 1)
 {
     $this->output->write(str_repeat("", $times));
 }
Esempio n. 7
0
 /**
  * Writes string to output using the error writer.
  *
  * @access  protected
  * @param   string     $string  String to write
  */
 protected function error($string)
 {
     $this->output->errorLn('<red>' . $string . '</red>');
 }