Exemple #1
0
    /** @return array */
    private function loadConfig()
    {
        $cmd = new CommandLine(<<<XX

FTP deployment v2.2
-------------------
Usage:
\tdeploy.php <config_file> [-t | --test]

Options:
\t-t | --test      Run in test-mode.
\t--generate       Only generates deployment file.

XX
, ['config' => [CommandLine::REALPATH => TRUE]]);
        if ($cmd->isEmpty()) {
            $cmd->help();
            return;
        }
        $options = $cmd->parse();
        $this->mode = $options['--generate'] ? 'generate' : ($options['--test'] ? 'test' : NULL);
        $this->configFile = $options['config'];
        return $this->loadConfigFile($options['config']);
    }
Exemple #2
0
    /** @return array */
    private function loadConfig()
    {
        $cmd = new CommandLine(<<<XX

FTP deployment v2.6
-------------------
Usage:
\tdeployment.php <config_file> [-t | --test]

Options:
\t-t | --test      Run in test-mode.
\t--generate       Only generates deployment file.
\t--no-progress    Hide the progress indicators.

XX
, ['config' => [CommandLine::REALPATH => TRUE]]);
        if ($cmd->isEmpty()) {
            $cmd->help();
            return;
        }
        $options = $cmd->parse();
        $this->mode = $options['--generate'] ? 'generate' : ($options['--test'] ? 'test' : NULL);
        $this->configFile = $options['config'];
        $config = $this->loadConfigFile($options['config']);
        if (!$config) {
            throw new \Exception('Missing config.');
        }
        $this->batches = isset($config['remote']) && is_string($config['remote']) ? ['' => $config] : array_filter($config, 'is_array');
        foreach ($this->batches as &$batch) {
            $batch = array_change_key_case($batch, CASE_LOWER) + $this->defaults;
        }
        $config = array_change_key_case($config, CASE_LOWER) + ['log' => preg_replace('#\\.\\w+$#', '.log', $this->configFile), 'tempdir' => sys_get_temp_dir() . '/deployment', 'progress' => TRUE, 'colors' => PHP_SAPI === 'cli' && (function_exists('posix_isatty') && posix_isatty(STDOUT) || getenv('ConEmuANSI') === 'ON' || getenv('ANSICON') !== FALSE)];
        $config['progress'] = $options['--no-progress'] ? FALSE : $config['progress'];
        return $config;
    }