Example #1
0
 function __construct($parent, $name, $docparser, $when_invoked)
 {
     parent::__construct($parent, $name, $docparser);
     $this->when_invoked = $when_invoked;
     $this->alias = $docparser->get_tag('alias');
     $this->synopsis = $docparser->get_synopsis();
     if (!$this->synopsis && $this->longdesc) {
         $this->synopsis = self::extract_synopsis($this->longdesc);
     }
 }
Example #2
0
 /**
  * Object constructor. Sets object properties
  *
  * @param CompositeCommand $parent       Parent command dispatcher object
  * @param string           $name         Name of command to run
  * @param DocParser        $docparser    DocParser object for analysis of docs
  * @param callable         $when_invoked Indicates classes & methods to use
  */
 public function __construct(CompositeCommand $parent, $name, DocParser $docparser, callable $when_invoked)
 {
     parent::__construct($parent, $name, $docparser);
     $this->when_invoked = $when_invoked;
     $this->alias = $docparser->getTag('alias');
     $this->synopsis = $docparser->getSynopsis();
     if (!$this->synopsis && $this->longdesc) {
         $this->synopsis = self::extractSynopsis($this->longdesc);
     }
 }
Example #3
0
 /**
  * Creates a new composite command
  *
  * @param CompositeCommand $parent     Parent command
  * @param string           $name       Name of command to create
  * @param \ReflectionClass $reflection Object with name of class to call
  * @param array            $options    Options to feed into a called command
  * @return CompositeCommand
  */
 private static function createCompositeCommand(CompositeCommand $parent, $name, \ReflectionClass $reflection, $options)
 {
     $docparser = new DocParser($reflection->getDocComment());
     // If the composite command already exists, don't recreate it.
     // This allows plugins to add to existing commands.
     $args = array($name);
     $container = $parent->findSubcommand($args);
     if (!$container) {
         $container = new CompositeCommand($parent, $name, $docparser);
     }
     foreach ($reflection->getMethods() as $method) {
         if (!self::isGoodMethod($method)) {
             continue;
         }
         $subcommand = self::createSubcommand($container, false, $reflection->name, $method, $options);
         $subcommand_name = $subcommand->getName();
         $container->addSubcommand($subcommand_name, $subcommand);
     }
     return $container;
 }
Example #4
0
 /**
  * Object constructor. Sets object properties
  *
  * @param CompositeCommand $parent       Parent command dispatcher object
  * @param string           $name         Name of command to run
  * @param DocParser        $docparser    DocParser object for analysis of docs
  * @param callable         $when_invoked Indicates classes & methods to use
  * @param array            $options      Options to be fed into command
  */
 public function __construct(CompositeCommand $parent, $name, DocParser $docparser, callable $when_invoked, array $options)
 {
     parent::__construct($parent, $name, $docparser);
     $this->when_invoked = $when_invoked;
     $this->alias = $docparser->getTag('alias');
     $this->config = $options['runner']->getConfig();
     $this->logger = $options['runner']->getLogger();
     $this->synopsis = $docparser->getSynopsis();
     if (!$this->synopsis && $this->longdesc) {
         $this->synopsis = self::extractSynopsis($this->longdesc);
     }
 }
Example #5
0
 function get_subcommands()
 {
     Utils\loadAllCommands();
     return parent::get_subcommands();
 }
Example #6
0
 /**
  * Gets the basic descriptions of a command's subcommands from internal docs
  *
  * @param CompositeCommand $command The command of which to get subcommands
  * @return string[] $subcommands An array of stringified
  *   subcommands of the command
  */
 private function getSubcommands($command)
 {
     $subcommands = array();
     foreach ($command->getSubcommands() as $subcommand) {
         if ($this->recursive) {
             $subcommands[$subcommand->getName()] = $this->getMarkdown($subcommand);
         } else {
             $subcommands[$subcommand->getName()] = $subcommand->getShortdesc();
         }
     }
     return $subcommands;
 }
Example #7
0
 /**
  * Returns all subcommands of the root command
  *
  * @return Subcommand[]
  */
 function getSubcommands()
 {
     $subcommands = parent::getSubcommands();
     return $subcommands;
 }
Example #8
0
 /**
  * Returns all subcommands of the root command
  *
  * @return Subcommand[]
  */
 function getSubcommands()
 {
     Utils\loadAllCommands();
     $subcommands = parent::getSubcommands();
     return $subcommands;
 }