Пример #1
0
 /**
  *
  * Handle power up event
  *
  * @param SimpleEvent $event
  *
  * @throws \ThinFrame\Foundation\Exceptions\Exception
  */
 public function onPowerUp(SimpleEvent $event)
 {
     if ($this->argumentsContainer->getArgumentAt(0) == 'compgen') {
         $this->commander->iterate(new CompletionIterator($this->argumentsContainer));
     } else {
         $this->commander->iterate($executor = new ExecuteIterator($this->argumentsContainer));
         if (!$executor->isStopped()) {
             throw new Exception('Cannot find the command you requested');
         }
     }
 }
Пример #2
0
 /**
  * This method will be called if this command is triggered
  *
  * @param ArgumentsContainer $arguments
  *
  * @return mixed
  */
 public function execute(ArgumentsContainer $arguments)
 {
     $descriptionsIterator = new DescriptionsIterator();
     $this->commander->iterate($descriptionsIterator);
     $maxSize = max(array_map('strlen', array_keys($descriptionsIterator->getDescriptions())));
     $this->outputDriver->send(PHP_EOL);
     foreach ($descriptionsIterator->getDescriptions() as $key => $value) {
         $this->outputDriver->send('  [format foreground="green" effects="bold"]{command}[/format]', ['command' => str_pad($key, $maxSize + 4, " ", STR_PAD_RIGHT)]);
         $this->outputDriver->send('- [format effects="bold"]{description}[/format]' . PHP_EOL, ['description' => $value]);
     }
     $this->outputDriver->send(PHP_EOL);
     exit(0);
 }