protected function help(Input $input, Output $output) { if ($desc = $this->getDescription()) { $output->br()->yellow($desc); } $sig = $this->getSignature(); $args = implode(' ', array_map(function ($arg) { $name = '<' . $arg['name'] . '>'; return $arg['required'] ? $name : '[' . $name . ']'; }, $sig['args'])); $output->br()->out('Usage: php ' . $_SERVER['PHP_SELF'] . ' ' . $this->getName() . ' ' . $args); if (count($sig['opts'])) { $output->br(); $optStrings = []; foreach ($sig['opts'] as $opt) { $long = $opt['long'] ? '--' . $opt['long'] : null; $short = $opt['short'] ? '-' . $opt['short'] : null; $optStrings[] = ['label' => ' ' . implode(', ', array_filter([$long, $short], 'strlen')) . ' ', 'description' => $opt['description']]; } $maxOptsLen = 0; foreach ($optStrings as $os) { if (mb_strlen($os['label']) > $maxOptsLen) { $maxOptsLen = mb_strlen($os['label']); } } $pad = $output->padding($maxOptsLen + 5, ' '); foreach ($optStrings as $os) { $pad->label($os['label'])->result($os['description']); } } $output->br(); }
public function execute(Input $input, Output $output) { $commands = $this->getConsole()->getCommands(); $output->br(); foreach ($commands as $command) { $output->padding(20)->label($command->getName())->result($command->getDescription()); } $output->br(); }