protected function execute(InputInterface $input, OutputInterface $output)
    {
        if ($root = $input->getArgument('root-dir')) {
            chdir(realpath($root));
        }

        $rootDir = realpath(getcwd());
        $logger  = new ConsoleLogger($output);

        $composerJson = $rootDir . '/composer.json';
        if (!file_exists($composerJson)) {
            $logger->error(
                '<error>File not found, can not analyze: {file}</error> ',
                array('file' => $composerJson)
            );

            return 1;
        }

        $destinations   = array();
        $destinations[] = new PsrLogDestination($logger);

        $report   = $this->prepareReport($input, $logger);
        $composer = json_decode(file_get_contents($composerJson), true);
        $ignore   = $this->getIgnoredFiles($composer, $input->getOption('ignore-files'));
        $factory  = new AutoloadValidatorFactory($rootDir, new ClassMapGenerator($ignore), $report);
        $test     = new AutoloadValidator($factory->createFromComposerJson($composer), $report);
        $test->validate();
        if ($report->hasError()) {
            $logger->error('<error>Testing loaders found errors</error> ');
        }

        $enumLoader = new EnumeratingClassLoader();
        $this->prepareLoader($enumLoader, $test);

        $hacker = new HackPreparator($enumLoader, $logger);
        if ($custom = $input->getOption('add-autoloader')) {
            $hacker->prepareHacks(
                $custom,
                array(
                    $rootDir,
                    dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'hacks'
                )
            );
        }
        $this->prepareComposerFallbackLoader($enumLoader, $rootDir, $composer);
        if (!($input->getOption('disable-legacy-hacks') || $input->getOption('add-autoloader'))) {
            $hacker->prepareLegacyHack();
        }

        $loadCycle = new AllLoadingAutoLoader($enumLoader, $test->getClassMap(), $logger);

        return static::$exitCodes[$loadCycle->run() && !$report->hasError()];
    }