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 "[33mSub Commands:[0m\n"; $padding += 4; foreach ($lines as $line) { echo ' ' . "[32m" . str_pad($line['name'], $padding) . "[0m" . $line['description'] . "\n"; } echo "\n"; } }
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())); }