protected function configureModules(InputInterface $input, OutputInterface $output, array $modules)
    {
        $app = $this->getApplication();
        if ($app->getConfiguration()) {
            $app->addCommands(ModuleCommand::getCommands());
            if ($app->getBitrixStatus() != \Notamedia\ConsoleJedi\Application\Application::BITRIX_STATUS_COMPLETE) {
                throw new BitrixException('Bitrix core is not available');
            }
        } else {
            throw new BitrixException('No configuration loaded');
        }

        if (!is_array($modules)) {
            throw new \LogicException('Incorrect modules configuration');
        }

        if (!count($modules)) {
            return;
        }

        $bar = new ProgressBar($output, count($modules));
        $bar->setRedrawFrequency(1);
        $bar->setFormat('verbose');

        foreach ($modules as $moduleName) {
            $message = "\r" . '   module:load ' . $moduleName . ': ';

            try {
                if (isset($bar)) {
                    $bar->setMessage($message);
                    $bar->display();
                }

                (new Module($moduleName))->load()->register();

                $bar->clear();
                $output->writeln($message . '<info>ok</info>');
            } catch (ModuleInstallException $e) {
                $bar->clear();
                $output->writeln($e->getMessage(), OutputInterface::VERBOSITY_VERBOSE);
                $output->writeln($message . '<comment>not registered</comment> (install it in admin panel)');
            } catch (ModuleException $e) {
                $bar->clear();
                $output->writeln($e->getMessage(), OutputInterface::VERBOSITY_VERBOSE);
                $output->writeln($message . '<error>FAILED</error>');
            }
            $bar->advance();
        }
        $bar->finish();
        $bar->clear();
        $output->write("\r");
    }