[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/joomla/console/src/Command/ -> HelpCommand.php (source)

   1  <?php
   2  /**
   3   * Part of the Joomla Framework Console Package
   4   *
   5   * @copyright  Copyright (C) 2005 - 2021 Open Source Matters, Inc. All rights reserved.
   6   * @license    GNU General Public License version 2 or later; see LICENSE
   7   */
   8  
   9  namespace Joomla\Console\Command;
  10  
  11  use Joomla\Console\Helper\DescriptorHelper;
  12  use Symfony\Component\Console\Input\InputArgument;
  13  use Symfony\Component\Console\Input\InputInterface;
  14  use Symfony\Component\Console\Output\OutputInterface;
  15  
  16  /**
  17   * Command to render a command's help data.
  18   *
  19   * @since  2.0.0
  20   */
  21  class HelpCommand extends AbstractCommand
  22  {
  23      /**
  24       * The default command name
  25       *
  26       * @var    string
  27       * @since  2.0.0
  28       */
  29      protected static $defaultName = 'help';
  30  
  31      /**
  32       * The command to process help for
  33       *
  34       * @var    AbstractCommand|null
  35       * @since  2.0.0
  36       */
  37      private $command;
  38  
  39      /**
  40       * Configure the command.
  41       *
  42       * @return  void
  43       *
  44       * @since   2.0.0
  45       */
  46  	protected function configure(): void
  47      {
  48          $this->setDescription('Show the help for a command');
  49          $this->setHelp(<<<'EOF'
  50  The <info>%command.name%</info> command displays a command's help information:
  51  
  52  <info>php %command.full_name% list</info>
  53  
  54  To display the list of available commands, please use the <info>list</info> command.
  55  EOF
  56          );
  57  
  58          $this->addArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help');
  59      }
  60  
  61      /**
  62       * Internal function to execute the command.
  63       *
  64       * @param   InputInterface   $input   The input to inject into the command.
  65       * @param   OutputInterface  $output  The output to inject into the command.
  66       *
  67       * @return  integer  The command exit code
  68       *
  69       * @since   2.0.0
  70       */
  71  	protected function doExecute(InputInterface $input, OutputInterface $output): int
  72      {
  73          if (!$this->command)
  74          {
  75              $this->command = $this->getApplication()->getCommand($input->getArgument('command_name'));
  76          }
  77  
  78          $descriptor = new DescriptorHelper;
  79  
  80          if ($this->getHelperSet() !== null)
  81          {
  82              $this->getHelperSet()->set($descriptor);
  83          }
  84  
  85          $descriptor->describe($output, $this->command);
  86  
  87          return 0;
  88      }
  89  
  90      /**
  91       * Set the command whose help is being presented.
  92       *
  93       * @param   AbstractCommand  $command  The command to process help for.
  94       *
  95       * @return  void
  96       *
  97       * @since   2.0.0
  98       */
  99  	public function setCommand(AbstractCommand $command): void
 100      {
 101          $this->command = $command;
 102      }
 103  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer