/** * Instantiate all command objects. We need them all instantiated so that * we can see if any has been selected for execution (i.e. the command * property of this object matches the command name or one of its aliases). * * @return void */ protected function instantiateCommands() { foreach ($this->commandClasses as $commandClass) { $fullClassName = '\\Dewdrop\\Cli\\Command\\' . $commandClass; $this->commands[$commandClass] = new $fullClassName($this, $this->renderer); } // Add any commands found in the project's commands folder $commandPath = $this->paths->getCommands(); if (is_dir($commandPath)) { $commands = glob($commandPath . '/*.php'); foreach ($commands as $command) { $className = '\\Command\\' . basename($command, '.php'); $this->commands[$className] = new $className($this, $this->renderer); } } // Add any custom commands defined in Pimple's "cli-commands" resource if (isset($this->pimple['cli-commands'])) { foreach ($this->pimple['cli-commands'] as $className) { $this->commands[$className] = new $className($this, $this->renderer); } } }