Mercurial > hg > isophonics-drupal-site
annotate vendor/consolidation/annotated-command/src/Help/HelpCommand.php @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 4c8ae668cc8c |
children |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 namespace Consolidation\AnnotatedCommand\Help; |
Chris@0 | 3 |
Chris@0 | 4 use Symfony\Component\Console\Application; |
Chris@0 | 5 use Symfony\Component\Console\Descriptor\XmlDescriptor; |
Chris@0 | 6 use Symfony\Component\Console\Input\InputInterface; |
Chris@0 | 7 use Symfony\Component\Console\Output\OutputInterface; |
Chris@0 | 8 |
Chris@0 | 9 class HelpCommand |
Chris@0 | 10 { |
Chris@0 | 11 /** var Application */ |
Chris@0 | 12 protected $application; |
Chris@0 | 13 |
Chris@0 | 14 /** |
Chris@0 | 15 * Create a help document from a Symfony Console command |
Chris@0 | 16 */ |
Chris@0 | 17 public function __construct(Application $application) |
Chris@0 | 18 { |
Chris@0 | 19 $this->application = $application; |
Chris@0 | 20 } |
Chris@0 | 21 |
Chris@0 | 22 public function getApplication() |
Chris@0 | 23 { |
Chris@0 | 24 return $this->application; |
Chris@0 | 25 } |
Chris@0 | 26 |
Chris@0 | 27 /** |
Chris@0 | 28 * Run the help command |
Chris@0 | 29 * |
Chris@0 | 30 * @command my-help |
Chris@0 | 31 * @return \Consolidation\AnnotatedCommand\Help\HelpDocument |
Chris@0 | 32 */ |
Chris@0 | 33 public function help($commandName = 'help') |
Chris@0 | 34 { |
Chris@0 | 35 $command = $this->getApplication()->find($commandName); |
Chris@0 | 36 |
Chris@0 | 37 $helpDocument = $this->getHelpDocument($command); |
Chris@0 | 38 return $helpDocument; |
Chris@0 | 39 } |
Chris@0 | 40 |
Chris@0 | 41 /** |
Chris@0 | 42 * Create a help document. |
Chris@0 | 43 */ |
Chris@0 | 44 protected function getHelpDocument($command) |
Chris@0 | 45 { |
Chris@0 | 46 return new HelpDocument($command); |
Chris@0 | 47 } |
Chris@0 | 48 } |