Returns cli-config file path
@param InputInterface $input
@return string
@throws \Exception
355666
private function getCliPath(InputInterface $input)
    {

        $filePaths = [
            __DIR__ . '/../../../config/sr-config.php',
            __DIR__ . '/../../../../../../sr-config.php',
            __DIR__ . '/../../../../../../config/sr-config.php',
        ];

        if ($input->hasOption('config')) {
            $filePaths[] = $input->getOption('config');
        }

        foreach ($filePaths as $path) {
            if (is_file($path)) {
                return $path;
            }
        }

        throw new \Exception(
            'There is not found config file.' . PHP_EOL .
            'You can pass path to file as option: -c FILE_PATH'
        );
    }
1351135
protected function getConfig(InputInterface $input)
    {
        /** @var $helper ConfigurationHelper */
        $helper = $this->getHelper('config');

        return $helper->loadFile($input->getOption('configuration'));
    }
1306371
public function load(InputInterface $input): ConfigInterface
    {
        $configFile = $input->getOption('config');
        if (!$configFile || !$this->filesystem->fileExists($configFile)) {
            throw InvalidArgumentException::invalidConfigFile();
        }
        $config = include $configFile;
        if (!$config instanceof ConfigInterface) {
            throw InvalidArgumentException::invalidConfigFile();
        }

        return $config;
    }
767927
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $path = $input->getOption('path');

        // if we're not given a path at all, try to figure it out
        if ($path === null) {
            $path = php_ini_loaded_file();
        }

        if (!is_file($path)) {
            throw new \Exception('Path is null or not accessible: "'.$path.'"');
        }
        $ini = parse_ini_file($path, true);

        $output->writeLn('Current PHP.ini settings from '.$path);
        $output->writeLn('##########');

        foreach ($ini as $section => $data) {
            $output->writeLn('<info>:: '.$section.'</info>');
            if (empty($data)) {
                $output->writeLn("\t<fg=yellow>No settings</fg=yellow>");
            } else {
                foreach ($data as $path => $value) {
                    $output->writeLn("\t".$path.' => '.var_export($value, true));
                }
            }
            $output->writeLn("-----------------\n");
        }

    }
869871
protected function loadConfiguration(InputInterface $input, $rootDir)
    {
        $coverallsYmlPath = $input->getOption('config');

        $ymlPath = $this->rootDir . DIRECTORY_SEPARATOR . $coverallsYmlPath;
        $configurator = new Configurator();

        return $configurator
            ->load($ymlPath, $rootDir, $input)
            ->setDryRun($input->getOption('dry-run'))
            ->setExcludeNoStatementsUnlessFalse($input->getOption('exclude-no-stmt'))
            ->setVerbose($input->getOption('verbose'))
            ->setEnv($input->getOption('env'));
    }
610372
protected function getStrategyOption(InputInterface $input)
    {
        $strategy = strtolower($input->getOption(MigrateMessage::OPT_STRATEGY));
        if (!isset($this->strategies[$strategy])) {
            throw new CliException(sprintf(
                'Unknown strategy "%s". Must be one of: %s',
                $strategy,
                implode(', ', array_keys($this->strategies))
            ));
        }

        return $this->strategies[$strategy];
    }
839861
private function getPassword(InputInterface $input, OutputInterface $output)
    {
        if ($pass = $input->getOption('pass')) {
            return $pass;
        }
        if ($pass = $this->getTransifexConfigValue('/pass')) {
            $this->writelnVerbose($output, 'Using transifex password specified in config.');

            return $pass;
        }
        if ($pass = getenv('transifexpass')) {
            $this->writelnVerbose($output, 'Using transifex password specified in environment.');

            return $pass;
        }
        if ($input->isInteractive()) {
            /** @var \Symfony\Component\Console\Helper\QuestionHelper $dialog */
            $dialog = $this->getHelperSet()->get('question');
            if ($pass = $dialog->ask($input, $output, (new Question('Transifex password:'))->setHidden(true))) {
                return $pass;
            }
        }

        throw new \RuntimeException('Error: you must either specify a password on the commandline or run interactive.');
    }
809136
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $path = $input->getOption('path');
        $context = array();

        // if we're not given a path at all, try to figure it out
        if ($path === null) {
            $path = php_ini_loaded_file();
        }

        if (!is_file($path)) {
            throw new \Exception('Path is null or not accessible: "'.$path.'"');
        }

        $scan = new \Psecio\Iniscan\Scan($path, $context);
        $scan->execute();

        $scan->getMarked();
        $result = pathinfo($path);

        // to start, we need a backup of the file (overwrite if there)
        $backupPath = './'.$result['basename'].'-'.date('mdy');
        copy($path, $backupPath);

        // Now les get our rules and parse them
        $scan = new \Psecio\Iniscan\Scan($path, $context);
        $rules = get_object_vars($scan->getRules());

        $output->writeLn($this->generateIniOutput($rules));
    }
484330
protected function getProgressBar(InputInterface $input)
    {
        $progress = parent::getProgressBar($input);
        if (!$progress) {
            return null;
        }

        $this->getService('event_dispatcher')->addListener(
            'parser.file.pre',
            function (PreFileEvent $event) use ($progress) {
                $progress->advance();
            }
        );

        return $progress;
    }
417052
protected function getLoader(Console\Input\InputInterface $input)
    {
        $inputFile = $input->getOption('input');

        if ($input->getOption('edit')) {
            if ($inputFile !== $this->getDefinition()->getOption('input')->getDefault()) {
                throw new \InvalidArgumentException("You cannot specify both --edit (-e) and --input (-i)");
            }
            $inputFile = $input->getOption('edit');
        }

        if ($inputFile === '-') {
            $inputFile = 'php://stdin';
            if (!($inputFormat = $input->getOption('input-format'))) {
                $inputFormat = 'json';
            }
        } elseif (!($inputFormat = $input->getOption('input-format'))) {
            // guess type based on extension.
            $inputFormat = Loader\Factory::guessType($inputFile);
        }

        $input->setOption('input-format', $inputFormat);

        $loader = Loader\Factory::createLoader($inputFormat);
        $inputStream = fopen($inputFile, 'r');
        if (!$inputStream) {
            throw new \RuntimeException("Could not open input");
        }

        if ($input->getOption('buffer') || $input->getOption('edit')) {
            $tmp = fopen('php://memory', 'rw');
            fwrite($tmp, stream_get_contents($inputStream));
            fseek($tmp, 0);
            $inputStream = $tmp;
        }
        $loader->setInput($inputStream);
        return $loader;
    }
826199
protected function getConfiguration(InputInterface $input)
    {
        $configuration = new Configuration();

        $configuration->setImagine($this->getImagine($input->getOption('driver')));
        $configuration->setOptions($input->getOption('options'));

        $configuration->getFinder()
               ->name($input->getArgument('pattern'))
               ->in($input->getArgument('source'));

        $configuration->setImage($input->getArgument('image'));
        $configuration->setColor(new Color($input->getOption('color'), $input->getOption('alpha')));
        $configuration->setStylesheet($input->getArgument('stylesheet'));
        $configuration->setSelector($input->getArgument('selector'));

        return $configuration;
    }
1041112
protected function getSites(InputInterface $input)
    {
        $parameters = [];
        $identifiers = $input->getOption('site');

        if ('all' !== current($identifiers)) {
            $parameters['id'] = 1 === \count($identifiers) ? current($identifiers) : $identifiers;
        }

        return $this->getSiteManager()->findBy($parameters);
    }
136960
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $config = new Config(
            $input->getOption('prod'),
            $input->getOption('destination'),
            '/sites/all/modules/%s',
            '/sites/all/themes/%s',
            '/sites/all/drush/%s',
            '/profiles/%s',
            '/sites/default/files',
            '/sites/default/files-private',
            '/sites/default/settings.php'
        );

        $finder = new Finder(
             $input->getOption('source'),
            $input->getOption('destination'),
            'cnf/files',
            'cnf/private',
            'cnf/settings.php'
        );

        $im = $this->getComposer()->getInstallationManager();
        $rm = $this->getComposer()->getRepositoryManager();

        $mapper = new Mapper($config, $finder, $im, $rm);
        $mapper->clear();
        $mapper->mirror($mapper->getMap());
    }
589179
protected function getMigrationConfiguration(
        InputInterface $input,
        OutputInterface $output
    ): Configuration {
        if (!$this->configuration) {
            $conn = $this->getDatabaseConnection($input);

            $outputWriter = new OutputWriter(function($message) use ($output) {
                return $output->writeln($message);
            });

            $migrationsConfigFile = $input->getOption('configuration');

            $this->configuration = ConfigurationBuilder::create()
                ->setConnection($conn)
                ->setOutputWriter($outputWriter)
                ->setOnDiskConfiguration($migrationsConfigFile)
                ->build();
        }

        return $this->configuration;
    }
1244787
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $path = $this->targetDirectory($input);

        $processName = $input->getArgument('process');

        if ($input->hasParameterOption(['--list', '-l']) || empty($processName)) {
            return $this->showProcesses($input, $output);
        }

        $processes = config()->get('processes', []);

        if (!isset($processes[$processName])) {
            throw new \RuntimeException(sprintf('Process %s cannot found', $processName));
        }

        $config = $processes[$processName];
        if (!class_exists($config['process'])) {
            throw new \RuntimeException(sprintf('Process class "%s" is not found.', $processName));
        }

        $name = $input->getOption('name');
        if (empty($name)) {
            $name = $processName;
        }
        $process = $config['process'];
        $options = isset($config['options']) ? (array) $config['options'] : [];
        $process = new $process($name);
        $process->configure($options);

        if (!($process instanceof Process)) {
            throw new \RuntimeException('Process must be instance of \FastD\Swoole\Process');
        }
        if ($input->hasParameterOption(['--daemon', '-d'])) {
            $process->daemon();
        }

        $pidFile = $path.'/'.$processName.'.pid';

        switch ($input->getArgument('action')) {
            case 'start':
                $pid = $process->start();
                file_put_contents($pidFile, $pid);
                $output->writeln(sprintf('process <info>%s</info> pid: <info>%s</info>', $process->getName(), $pid));
                $output->writeln(sprintf('pid: <info>%s</info>', $pidFile));

                $process->wait(function ($ret) use ($name) {
                    return $this->finish($name, $ret['pid'], $ret['code'], $ret['signal']);
                });

                break;
            case 'stop':
                $pid = (int) file_get_contents($pidFile);
                if ($process->kill($pid, SIGTERM)) {
                    $output->writeln(sprintf('process %s pid %s is killed', $process->getName(), $pid));
                }

                break;
            case 'status':
            default:
                $table = new Table($output);
                $info = $this->getProcessInfo($name);
                $table->setColumnWidth(0, 15);
                $rows = [
                    ['name', sprintf('<info>%s</info>', $process->getName())],
                    ['class', sprintf('<info>%s</info>', get_class($process))],
                    ['status', sprintf('<info>%s</info>', $info[2])],
                    ['pid', sprintf('<info>%s</info>', $info[1])],
                ];
                foreach ($options as $key => $value) {
                    $rows[] = ['options.'.$key, sprintf('<info>%s</info>', $value)];
                }
                $table->setRows($rows);
                $table->setStyle('compact');
                $table->render();
        }

        return 0;
    }
463972
protected function getConfigFile()
    {
        $inputPath = $this->input->getArgument('path');

        $dir = './';

        if (1 == count($inputPath) && $first = reset($inputPath)) {
            $dir = is_dir($first) ? $first : dirname($first);
        }

        $filename = rtrim($dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'.phplint.yml';

        return realpath($filename);
    }
326693
final public function console(InputInterface $input)
    {
        if (!$input) {
            $input = new ArgvInput();
        }
        $application = new Application($this);
        return $application->run($input);
    }