Ejemplo n.º 1
0
 private function displaySubCommandHelp(Context $context)
 {
     $contexts = $this->application->getContexts();
     $lines = [];
     $padding = 0;
     foreach ($contexts[$context->getName()]['children'] as $child) {
         /** @var Context $child */
         $name = $child->getName();
         $lines[] = ['name' => substr($name, strrpos($name, ' ')), 'description' => $child->getDescription()];
         if (($length = strlen($name)) > $padding) {
             $padding = $length;
         }
     }
     if (!empty($lines)) {
         echo "Sub Commands:\n";
         $padding += 4;
         foreach ($lines as $line) {
             echo '  ' . "" . str_pad($line['name'], $padding) . "" . $line['description'] . "\n";
         }
         echo "\n";
     }
 }
Ejemplo n.º 2
0
 public function run($args = null)
 {
     global $argv;
     if ($args === null) {
         $args = $argv;
         $args[0] = $this->name;
     }
     if ($this->root->run($args)) {
         return;
     }
     foreach ($this->contexts as $context) {
         if ($context['instance']->run($args)) {
             return;
         }
     }
     $this->dispatcher->dispatch(self::EVENT_INVALID_USAGE, new InvalidUsageEvent($args, $this->root->getOptionDefinitions()));
 }