Load bundle's commands.
@param  \Asgard\Console\Application $console
176090
protected function loadCommands($console) {
		if(file_exists($this->getPath().'/Command/')) {
			foreach(glob($this->getPath().'/Command/*.php') as $filename) {
				$class = \Asgard\Common\Tools::loadClassFile($filename);
				if(is_subclass_of($class, 'Symfony\Component\Console\Command\Command')) {
					try {
						$console->add(new $class);
					}
					catch(\Exception $e) {} #ignore if it cannot be instantiated without arguments
					catch(\Throwable $e) {} #ignore if it cannot be instantiated without arguments
				}
			}
		}
	}
896556
public function run($console = false)
    {
        $commands = $this->commands;

        is_string($commands) && $commands = $this->classes();

        foreach ((array) $commands as $command) {
            $item = $this->container->get($command);

            $this->console->add($instance = $item);
        }

        $console === false && $this->console->run();

        return $this->console;
    }
1217781
function runConsole()
    {
        $app = new  Symfony\Component\Console\Application("<info>Swoole Framework</info> Console Tool.");
        $app->add(new Swoole\Command\MakeController());
        $app->add(new Swoole\Command\MakeModel());
        $app->add(new Swoole\Command\MakeConfig());
        $app->run();
    }
737187
public static function load(BundleInterface $bundle)
    {
        if (is_dir($bundle->getPath())) {
            self::$bundlesLoaded[$bundle->getName()] = [
                'namespace' => $bundle->getNamespace(),
                'path' => $bundle->getPath()
            ];

            if (!self::$classLoader) {
                self::$classLoader = new ClassLoader();
            }

            self::$classLoader->addPsr4($bundle->getNamespace(), $bundle->getPath());
            self::$classLoader->register();
        } else {
            throw new MissingBundleException(sprintf('Bundle "%s" could not be found.', $bundle->getName()));
        }
    }
181553
public function fire(Command $console, $slug)
    {
        $this->console = $console;
        $this->slug = strtolower($slug);
        $this->name = Str::studly($slug);

        if ($this->pluggable->exists($this->slug)) {
            $console->comment('Pluggable [{$this->name}] already exists.');

            return false;
        }

        $this->generate($console);
    }
188112
public function registerCommands(Application $application)
    {
        if (!is_dir($dir = $this->getPath() . '/Command')) {
            return;
        }
        $explorer = new Explorer($dir);
        $explorer->setSearchPattern('/[a-zA-Z0-9]Command\.php$/i');
        
        $prefixNS = $this->getNamespace() . '\\Command';
        foreach ($explorer->getFiles() as $file) {
            $namespace = $prefixNS;
            $class = $namespace . '\\' . $file->getBasename('.php');
            $r = new \ReflectionClass($class);
            if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract() && !$r->getConstructor()->getNumberOfRequiredParameters()) {
                $application->add($r->newInstance());
            }
        }
    }
484551
public function run()
    {
        $console = $this->console;
        $this->app->instance('console', $console);

        $this->loadBootstrap();
        $this->initializeSystemTimezone();

        $input = new ArgvInput();
        if ($input->getFirstArgument() !== 'c5:update') {
            if ($this->app->isInstalled()) {
                $this->app->setupPackageAutoloaders();
                $this->app->setupPackages();
            }
        }

        // Handle legacy backwards compatibility
        if (method_exists($console, 'setupDefaultCommands')) {
            $console->setupDefaultCommands();
        }

        \Events::dispatch('on_before_console_run');

        $console->run($input);

        \Events::dispatch('on_after_console_run');
    }
257741
protected function execute(InputInterface $input, OutputInterface $output)
    {
        /**
         * GENERATE THE BUNDLEBUNDLE
         */
        $bundleBundleDir = sprintf(self::BUNDLE_NAME_MASK, 'Bundle');

        // GravitonDynBundleBundle
        $bundleName = str_replace('/', '', $bundleBundleDir);

        // bundlebundle stuff..
        $this->bundleBundleNamespace = $bundleBundleDir;
        $this->bundleBundleDir = $input->getOption('srcDir') . $bundleBundleDir;
        $this->bundleBundleClassname = $bundleName;
        $this->bundleBundleClassfile = $this->bundleBundleDir . '/' . $this->bundleBundleClassname . '.php';

        $filesToWorkOn = $this->definitionLoader->load($input->getOption('json'));

        if (count($filesToWorkOn) < 1) {
            throw new \LogicException("Could not find any usable JSON files.");
        }

        $templateHash = $this->getTemplateHash();
        $existingBundles = $this->getExistingBundleHashes($input->getOption('srcDir'));

        /**
         * GENERATE THE BUNDLE(S)
         */
        foreach ($filesToWorkOn as $jsonDef) {
            $thisIdName = $jsonDef->getId();
            $namespace = sprintf(self::BUNDLE_NAME_MASK, $thisIdName);

            // make sure bundle is in bundlebundle
            $this->bundleBundleList[] = $namespace;

            $jsonDef->setNamespace($namespace);

            $bundleName = str_replace('/', '', $namespace);
            $bundleDir = $input->getOption('srcDir').$namespace;
            $bundleNamespace = str_replace('/', '\\', $namespace).'\\';

            try {
                $thisHash = sha1($templateHash.PATH_SEPARATOR.serialize($jsonDef));

                $needsGeneration = true;
                if (isset($existingBundles[$bundleDir])) {
                    if ($existingBundles[$bundleDir] == $thisHash) {
                        $needsGeneration = false;
                    }
                    unset($existingBundles[$bundleDir]);
                }

                if ($needsGeneration) {
                    $this->generateBundle($bundleNamespace, $bundleName, $input->getOption('srcDir'));
                    $this->generateGenerationHashFile($bundleDir, $thisHash);
                }

                if ($needsGeneration) {
                    $this->generateResources(
                        $jsonDef,
                        $bundleName,
                        $bundleDir,
                        $bundleNamespace
                    );

                    $output->write(
                        PHP_EOL.
                        sprintf('<info>Generated "%s" from definition %s</info>', $bundleName, $jsonDef->getId()).
                        PHP_EOL
                    );
                } else {
                    $output->write(
                        PHP_EOL.
                        sprintf('<info>Using pre-existing "%s"</info>', $bundleName).
                        PHP_EOL
                    );
                }
            } catch (\Exception $e) {
                $output->writeln(
                    sprintf('<error>%s</error>', $e->getMessage())
                );

                // remove failed bundle from list
                array_pop($this->bundleBundleList);
            }
        }

        // whatever is left in $existingBundles is not defined anymore and needs to be deleted..
        foreach ($existingBundles as $dirName => $hash) {
            $fileInfo = new \SplFileInfo($dirName);
            $bundleClassName = $this->getBundleClassnameFromFolder($fileInfo->getFilename());

            // remove from bundlebundle list
            unset($this->bundleBundleList[array_search($bundleClassName, $this->bundleBundleList)]);

            $this->fs->remove($dirName);

            $output->write(
                PHP_EOL.
                sprintf('<info>Deleted obsolete bundle "%s"</info>', $dirName).
                PHP_EOL
            );
        }

        // generate bundlebundle
        $this->generateBundleBundleClass();
    }
170236
protected function registerCommands()
    {
        if ($this->app->runningInConsole()) {
            $this->commands([
                Console\InstallCommand::class,
                Console\AssetsCommand::class,
                Console\HorizonCommand::class,
                Console\ListCommand::class,
                Console\PurgeCommand::class,
                Console\PauseCommand::class,
                Console\ContinueCommand::class,
                Console\StatusCommand::class,
                Console\SupervisorCommand::class,
                Console\SupervisorsCommand::class,
                Console\TerminateCommand::class,
                Console\TimeoutCommand::class,
                Console\WorkCommand::class,
            ]);
        }

        $this->commands([Console\SnapshotCommand::class]);
    }
528385
public function add_commands() {
		/**
		 * Search for other Skeleton packages installed
		 */
		$skeletons = \Skeleton\Core\Skeleton::get_all();

		/**
		 * Check in every Skeleton package for commands
		 */
		foreach ($skeletons as $skeleton) {

			if (!file_exists($skeleton->path . '/console')) {
				continue;
			}

			$files = scandir($skeleton->path . '/console');

			foreach ($files as $file) {
				if ($file[0] == '.') {
					continue;
				}
				require_once $skeleton->path . '/console/' . $file;

				$file = str_replace('.php', '', $file);

				$classname = '\Skeleton\Console\Command\\' . ucfirst(str_replace('-', '_', str_replace('skeleton-', '', $skeleton->name))) . '_' . ucfirst($file);
				$this->add(new $classname);
			}
		}
	}
925341
def run(self):
        """"""
        self.console.load(self.lines, setup=self.setup, teardown=self.teardown)
        return self.console.interpret()
658212
private function cmdAutoload($args)
    {
        $cmd = new AutoloadCommand($this->cwd);

        return $cmd->run(array_slice($args, 1));
    }
66676
static public function addCommands(Application $cli)
    {
        $cli->addCommands(array(
            // DBAL Commands
            new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(),
            new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(),

            // ORM Commands
            new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(),
            new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(),
            new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(),
            new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(),
            new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(),
            new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(),
            new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(),
            new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(),
            new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(),
            new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(),
            new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(),
            new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(),
            new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(),
            new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand(),
            new \Doctrine\ORM\Tools\Console\Command\InfoCommand(),
            new \Doctrine\ORM\Tools\Console\Command\MappingDescribeCommand(),
        ));
    }
869106
public function load(array $commandClasses)
    {
        foreach ($commandClasses as $commandClass) {
            $command = \Parable\DI\Container::create($commandClass);
            $this->consoleApp->addCommand($command);
        }
        return $this;
    }
344492
public function doExecute(Console $console) {
        if (file_exists($this->targetFile)) {
            $console->out->writeLine('Already exists');
            return;
        }

        $creator = new Creator();
        $creator->createStub($this->baseClass, $this->targetFile);
        $console->out->writeLine('Created user configuration in ' . $this->targetFile);
    }
232722
public function registerCommands(Application $application)
    {
        foreach ($this->getCommands() as $command) {
            $application->add($command);
        }
    }
408556
public static function setup(Event $event)
    {
        $consoleDir = ComposerHelper::getConsoleDir();
        if (null === $consoleDir) {
            throw new \RuntimeException('Console not found');
        }

        /* Doctrine Migrations */
        if (true === class_exists(DoctrineMigrationsBundle::class)) {
            ComposerHelper::write($event, 'DoctrineMigrationsBundle exist. Start migrations.');

            ComposerHelper::executeCommand($event, $consoleDir, 'doctrine:migrations:migrate', 600);
        }
    }