Returns an array of commands an their descriptions.
@return array all available commands as keys and their description as values.
507802
protected function getCommandDescriptions()
    {
        $descriptions = [];
        foreach ($this->getCommands() as $command) {
            $description = '';

            $result = $this->app->createController($command);
            if ($result !== false && $result[0] instanceof Controller) {
                [$controller, $actionID] = $result;
                /** @var Controller $controller */
                $description = $controller->getHelpSummary();
            }

            $descriptions[$command] = $description;
        }

        return $descriptions;
    }
1026296
protected function getDefaultCommands()
    {
        $commands = parent::getDefaultCommands();
        $commands[] = new Command\AboutCommand();
        $commands[] = new Command\ConfigCommand();
        $commands[] = new Command\DependsCommand();
        $commands[] = new Command\InitCommand();
        $commands[] = new Command\InstallCommand();
        $commands[] = new Command\CreateProjectCommand();
        $commands[] = new Command\UpdateCommand();
        $commands[] = new Command\SearchCommand();
        $commands[] = new Command\ValidateCommand();
        $commands[] = new Command\ShowCommand();
        $commands[] = new Command\RequireCommand();
        $commands[] = new Command\DumpAutoloadCommand();
        $commands[] = new Command\StatusCommand();
        $commands[] = new Command\ArchiveCommand();
        $commands[] = new Command\DiagnoseCommand();
        $commands[] = new Command\RunScriptCommand();
        $commands[] = new Command\LicensesCommand();
        $commands[] = new Command\GlobalCommand();
        $commands[] = new Command\ClearCacheCommand();
        $commands[] = new Command\RemoveCommand();
        $commands[] = new Command\HomeCommand();

        if ('phar:' === substr(__FILE__, 0, 5)) {
            $commands[] = new Command\SelfUpdateCommand();
        }

        return $commands;
    }
236180
public List<AbstractCommand> getCommands()
    {
        return commands.values().stream()
                        .map(id -> AbstractCommand.search(id))
                        .collect(Collectors.toList());
    }
1137491
def commands(self):
        
        if self._commands is None:
            self._commands = CommandList(self)
        return self._commands
1218150
public function getArgumentDefinitions(): array
    {
        if (!$this->hasArguments()) {
            return [];
        }
        $commandArgumentDefinitions = [];
        $commandMethodReflection = $this->getCommandMethodReflection();
        $annotations = $commandMethodReflection->getTagsValues();
        $commandParameters = $this->reflectionService->getMethodParameters($this->controllerClassName, $this->controllerCommandName . 'Command');
        $i = 0;
        foreach ($commandParameters as $commandParameterName => $commandParameterDefinition) {
            $explodedAnnotation = explode(' ', $annotations['param'][$i]);
            array_shift($explodedAnnotation);
            array_shift($explodedAnnotation);
            $description = implode(' ', $explodedAnnotation);
            $required = $commandParameterDefinition['optional'] !== true;
            $commandArgumentDefinitions[] = new CommandArgumentDefinition($commandParameterName, $required, $description);
            $i ++;
        }
        return $commandArgumentDefinitions;
    }
262921
function getCommandHelps() {
        const cmds = {},
            topics = {},
            result = ['Registered commands:'];
        let keys = {};
        Object.keys(handlers).map((key) => {
            keys[key] = 1;
        });
        Object.keys(helpTopics).map((key) => {
            keys[key] = 1;
        });
        Object.keys(keys).map((key) => {
            if (handlers[key]) {
                cmds[key] = handlers[key].help;
                if (helpTopics[key]) {
                    cmds[key] += ' *';
                }
            } else {
                topics[key] = 'Extended help topic';
            }
        });
        keys = Object.keys(cmds);
        keys.sort();
        keys.forEach((cmd) => result.push(`${cmd}: ${cmds[cmd]}`));
        keys = Object.keys(topics);
        if (keys.length) {
            result.push('');
            result.push('Help Topics:');
            keys.sort();
            keys.forEach((topic) => result.push(`${topic}: ${topics[topic]}`));
        }
        return result.join('\n');
    }
823359
private function getAvailableCommands()
    {
        $commands = $this->getDefaultPiwikCommands();
        $detected = PluginManager::getInstance()->findMultipleComponents('Commands', 'Piwik\\Plugin\\ConsoleCommand');

        $commands = array_merge($commands, $detected);

        /**
         * Triggered to filter / restrict console commands. Plugins that want to restrict commands
         * should subscribe to this event and remove commands from the existing list.
         *
         * **Example**
         *
         *     public function filterConsoleCommands(&$commands)
         *     {
         *         $key = array_search('Piwik\Plugins\MyPlugin\Commands\MyCommand', $commands);
         *         if (false !== $key) {
         *             unset($commands[$key]);
         *         }
         *     }
         *
         * @param array &$commands An array containing a list of command class names.
         */
        Piwik::postEvent('Console.filterCommands', array(&$commands));

        $commands = array_values(array_unique($commands));

        return $commands;
    }
996868
public function listCommands()
    {
        $commands = $this->library->getAll();

        foreach ($commands as $name => $details) {
            $this->output->writeln(ucwords($name));
            $this->output->hr(strlen($details['description']), '-');
            $this->output->writeln($details['description']);
            $this->output->hr(strlen($details['description']), '-');

            foreach ($details['actions'] as $action) {
                $this->output->writeln(
                    sprintf(
                        "%s - php [file] %s%s [params]",
                        $action,
                        $name,
                        ($action != 'main' ? ":$action" : '')
                    )
                );
            }

            // Just for padding
            $this->output->writeln('');
        }
    }
768691
private function getDescriptors(): array
    {
        if ($this->input instanceof \Iterator) {
            $this->input->rewind();
        }
        if ('\\' === \DIRECTORY_SEPARATOR) {
            $this->processPipes = new WindowsPipes($this->input, !$this->outputDisabled || $this->hasCallback);
        } else {
            $this->processPipes = new UnixPipes($this->isTty(), $this->isPty(), $this->input, !$this->outputDisabled || $this->hasCallback);
        }

        return $this->processPipes->getDescriptors();
    }
555771
public function getInvertedCommands()
    {
        $inverted = new Intent();

        foreach (array_reverse($this->commands) as $com) {
            switch (true) {
                case $com instanceof CreateTable:
                    $inverted->addAction(new DropTable($com->getTable()));
                    break;

                case $com instanceof RenameTable:
                    $inverted->addAction(new RenameTable(new Table($com->getNewName()), $com->getTable()->getName()));
                    break;

                case $com instanceof AddColumn:
                    $inverted->addAction(new RemoveColumn($com->getTable(), $com->getColumn()));
                    break;

                case $com instanceof RenameColumn:
                    $column = clone $com->getColumn();
                    $name = $column->getName();
                    $column->setName($com->getNewName());
                    $inverted->addAction(new RenameColumn($com->getTable(), $column, $name));
                    break;

                case $com instanceof AddIndex:
                    $inverted->addAction(new DropIndex($com->getTable(), $com->getIndex()));
                    break;

                case $com instanceof AddForeignKey:
                    $inverted->addAction(new DropForeignKey($com->getTable(), $com->getForeignKey()));
                    break;

                default:
                    throw new IrreversibleMigrationException(sprintf(
                        'Cannot reverse a "%s" command',
                        get_class($com)
                    ));
            }
        }

        return $inverted;
    }
1146722
public function getCommands()
    {
        $short = new ProviderShort();

        return array_merge(
            $short->getCommands(),
            array(
                new CodeBeautifierFixer(),
                new CodeCoverage(),
                new CodeSniffer(),
                new CopyPasteDetector(),
                new Fixer(),
                new LineOfCode(),
                new Lint(),
                new MessDetector(),
                new ParaTest(),
                new PHPCSFixer(),
                new PHPMetrics(),
                new SecurityChecker(),
                new Test(),
            )
        );
    }
1158601
private function prepareCommands(): array
    {
        $batches = array_chunk($this->queue, $this->batchSize);
        $this->queue = [];

        $commands = [];
        foreach ($batches as $batch) {
            $requests = [];
            foreach ($batch as $item) {
                if (!isset($requests[$item['table']])) {
                    $requests[$item['table']] = ['Keys' => [], 'ConsistentRead' => $this->consistentRead];
                }
                $requests[$item['table']]['Keys'][] = $item['key'];
            }
            $commands[] = $this->client->getCommand('BatchGetItem', ['RequestItems' => $requests]);
        }

        return $commands;
    }
1203478
public function toArray()
    {
        $commands = array();

        $maybeAppend = function ($command) use (&$commands) {
            if ($command) $commands []= (string) $command;
        };

        if ($this->metadataOnly) {
            $commands []= 'meta';
        }

        $maybeAppend($this->trim);
        $maybeAppend($this->crop);
        $maybeAppend($this->resize);
        $maybeAppend($this->halign);
        $maybeAppend($this->valign);

        if ($this->smartCrop) {
            $commands []= 'smart';
        }

        if (count($this->filters)) {
            $filters = 'filters:' . implode(':', $this->filters);
            $commands []= $filters;
        }

        return $commands;
    }
504392
public function getAvailableCommands(): array
    {
        if ($this->availableCommands === null) {
            $this->availableCommands = [];

            foreach (static::getCommandControllerMethodArguments($this->objectManager) as $className => $methods) {
                foreach (array_keys($methods) as $methodName) {
                    $this->availableCommands[] = new Command($className, substr($methodName, 0, -7));
                }
            }
        }

        return $this->availableCommands;
    }
413241
private function availableCommands()
    {
        return [
            self::INSTALL,
            self::UPDATE,
            self::DUMP_AUTOLOAD,
            self::DOWNLOAD,
            self::REMOVE,
        ];
    }
1139754
public function hydrateCommands(array $commands) : array
    {
        $modulesDone = [];

        foreach ($this->finder->getModuleList() as $module) {
            $moduleName = basename($module);

            if (!\in_array($moduleName, $modulesDone, true)) {
                $facade = Locator::getInstance()->{$moduleName}()->facade();
                if (method_exists($facade, 'getCommands')) {
                    $commands = \array_merge($commands, $facade->getCommands());
                }
                $modulesDone[] = $moduleName;
            }
        }

        return $commands;
    }
904973
protected function getModulesCommands()
    {
        $commands = [];

        foreach (ModuleManager::getInstalledModules() as $module) {
            $cliFile = getLocalPath('modules/' . $module['ID'] . '/cli.php');

            if ($cliFile === false) {
                continue;
            } elseif (!Loader::includeModule($module['ID'])) {
                continue;
            }

            $config = include_once $this->getDocumentRoot() . $cliFile;

            if (isset($config['commands']) && is_array($config['commands'])) {
                $commands = array_merge($commands, $config['commands']);
            }
        }

        return $commands;
    }