@@ -2,8 +2,6 @@ |
||
| 2 | 2 | namespace Consolidation\OutputFormatters\Formatters; |
| 3 | 3 | |
| 4 | 4 | use Consolidation\OutputFormatters\Options\FormatterOptions; |
| 5 | -use Consolidation\OutputFormatters\Validate\ValidDataTypesInterface; |
|
| 6 | -use Consolidation\OutputFormatters\Validate\ValidDataTypesTrait; |
|
| 7 | 5 | use Symfony\Component\Console\Output\OutputInterface; |
| 8 | 6 | use Symfony\Component\Console\Helper\Table; |
| 9 | 7 | use Symfony\Component\Console\Helper\TableCell; |
@@ -14,11 +14,11 @@ discard block |
||
| 14 | 14 | class HelpFormatter implements FormatterInterface |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * @inheritdoc |
|
| 19 | - */ |
|
| 20 | - public function write(OutputInterface $output, $data, FormatterOptions $options) |
|
| 21 | - { |
|
| 17 | + /** |
|
| 18 | + * @inheritdoc |
|
| 19 | + */ |
|
| 20 | + public function write(OutputInterface $output, $data, FormatterOptions $options) |
|
| 21 | + { |
|
| 22 | 22 | $table = new Table($this->output()); |
| 23 | 23 | $table->setStyle('compact'); |
| 24 | 24 | |
@@ -26,51 +26,51 @@ discard block |
||
| 26 | 26 | $output->writeln($command->getDescription()); |
| 27 | 27 | |
| 28 | 28 | if ($usages = $command->getExampleUsages()) { |
| 29 | - $table->addRow(['','']); |
|
| 30 | - $table->addRow([new TableCell('Examples:', array('colspan' => 2))]); |
|
| 31 | - foreach ($usages as $key => $description) { |
|
| 29 | + $table->addRow(['','']); |
|
| 30 | + $table->addRow([new TableCell('Examples:', array('colspan' => 2))]); |
|
| 31 | + foreach ($usages as $key => $description) { |
|
| 32 | 32 | $table->addRow([' ' . $key, $description]); |
| 33 | - } |
|
| 33 | + } |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | if ($arguments = $def->getArguments()) { |
| 37 | - $table->addRow(['','']); |
|
| 38 | - $table->addRow([new TableCell('Arguments:', array('colspan' => 2))]); |
|
| 39 | - foreach ($arguments as $argument) { |
|
| 37 | + $table->addRow(['','']); |
|
| 38 | + $table->addRow([new TableCell('Arguments:', array('colspan' => 2))]); |
|
| 39 | + foreach ($arguments as $argument) { |
|
| 40 | 40 | $formatted = $this->formatArgumentName($argument); |
| 41 | 41 | $description = $argument->getDescription(); |
| 42 | 42 | if ($argument->getDefault()) { |
| 43 | - $description .= ' [default: ' . $argument->getDefault() . ']'; |
|
| 43 | + $description .= ' [default: ' . $argument->getDefault() . ']'; |
|
| 44 | 44 | } |
| 45 | 45 | $table->addRow([' ' . $formatted, $description]); |
| 46 | - } |
|
| 46 | + } |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | if ($options = $def->getOptions()) { |
| 50 | - $table->addRow(['','']); |
|
| 51 | - $table->addRow([new TableCell('Options:', array('colspan' => 2))]); |
|
| 52 | - foreach ($options as $option) { |
|
| 50 | + $table->addRow(['','']); |
|
| 51 | + $table->addRow([new TableCell('Options:', array('colspan' => 2))]); |
|
| 52 | + foreach ($options as $option) { |
|
| 53 | 53 | $formatted = $this->formatOption($option); |
| 54 | 54 | $table->addRow([' ' . $formatted, $option->getDescription()]); |
| 55 | - } |
|
| 55 | + } |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | if ($topics = $command->getTopics()) { |
| 59 | - $table->addRow(['','']); |
|
| 60 | - $table->addRow([new TableCell('Topics:', array('colspan' => 2))]); |
|
| 61 | - foreach ($topics as $topic) { |
|
| 59 | + $table->addRow(['','']); |
|
| 60 | + $table->addRow([new TableCell('Topics:', array('colspan' => 2))]); |
|
| 61 | + foreach ($topics as $topic) { |
|
| 62 | 62 | // @todo deal with long descriptions |
| 63 | 63 | $table->addRow([' ' . $topic, substr($allTopics[$topic]['description'], 0, 30)]); |
| 64 | - } |
|
| 64 | + } |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | if ($aliases = $command->getAliases()) { |
| 68 | - $table->addRow(['','']); |
|
| 69 | - $table->addRow([new TableCell('Aliases: '. implode(' ', $aliases), array('colspan' => 2))]); |
|
| 68 | + $table->addRow(['','']); |
|
| 69 | + $table->addRow([new TableCell('Aliases: '. implode(' ', $aliases), array('colspan' => 2))]); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $table->render(); |
| 73 | 73 | |
| 74 | 74 | $output->writeln($help); |
| 75 | - } |
|
| 75 | + } |
|
| 76 | 76 | } |
@@ -26,47 +26,47 @@ |
||
| 26 | 26 | $output->writeln($command->getDescription()); |
| 27 | 27 | |
| 28 | 28 | if ($usages = $command->getExampleUsages()) { |
| 29 | - $table->addRow(['','']); |
|
| 29 | + $table->addRow(['', '']); |
|
| 30 | 30 | $table->addRow([new TableCell('Examples:', array('colspan' => 2))]); |
| 31 | 31 | foreach ($usages as $key => $description) { |
| 32 | - $table->addRow([' ' . $key, $description]); |
|
| 32 | + $table->addRow([' '.$key, $description]); |
|
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | if ($arguments = $def->getArguments()) { |
| 37 | - $table->addRow(['','']); |
|
| 37 | + $table->addRow(['', '']); |
|
| 38 | 38 | $table->addRow([new TableCell('Arguments:', array('colspan' => 2))]); |
| 39 | 39 | foreach ($arguments as $argument) { |
| 40 | 40 | $formatted = $this->formatArgumentName($argument); |
| 41 | 41 | $description = $argument->getDescription(); |
| 42 | 42 | if ($argument->getDefault()) { |
| 43 | - $description .= ' [default: ' . $argument->getDefault() . ']'; |
|
| 43 | + $description .= ' [default: '.$argument->getDefault().']'; |
|
| 44 | 44 | } |
| 45 | - $table->addRow([' ' . $formatted, $description]); |
|
| 45 | + $table->addRow([' '.$formatted, $description]); |
|
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | if ($options = $def->getOptions()) { |
| 50 | - $table->addRow(['','']); |
|
| 50 | + $table->addRow(['', '']); |
|
| 51 | 51 | $table->addRow([new TableCell('Options:', array('colspan' => 2))]); |
| 52 | 52 | foreach ($options as $option) { |
| 53 | 53 | $formatted = $this->formatOption($option); |
| 54 | - $table->addRow([' ' . $formatted, $option->getDescription()]); |
|
| 54 | + $table->addRow([' '.$formatted, $option->getDescription()]); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | if ($topics = $command->getTopics()) { |
| 59 | - $table->addRow(['','']); |
|
| 59 | + $table->addRow(['', '']); |
|
| 60 | 60 | $table->addRow([new TableCell('Topics:', array('colspan' => 2))]); |
| 61 | 61 | foreach ($topics as $topic) { |
| 62 | 62 | // @todo deal with long descriptions |
| 63 | - $table->addRow([' ' . $topic, substr($allTopics[$topic]['description'], 0, 30)]); |
|
| 63 | + $table->addRow([' '.$topic, substr($allTopics[$topic]['description'], 0, 30)]); |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | if ($aliases = $command->getAliases()) { |
| 68 | - $table->addRow(['','']); |
|
| 69 | - $table->addRow([new TableCell('Aliases: '. implode(' ', $aliases), array('colspan' => 2))]); |
|
| 68 | + $table->addRow(['', '']); |
|
| 69 | + $table->addRow([new TableCell('Aliases: '.implode(' ', $aliases), array('colspan' => 2))]); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $table->render(); |