Returns the output from running the "rollback" command.
@param  string $env environment name (optional)
@param  mixed $target target version, or 0 (zero) fully revert (optional)
@return string
6739
public function getRollback($env = null, $target = null)
    {
        $command = ['rollback'];
        if ($env ?: $this->hasOption('environment')) {
            $command += ['-e' => $env ?: $this->getOption('environment')];
        }
        if ($this->hasOption('configuration')) {
            $command += ['-c' => $this->getOption('configuration')];
        }
        if ($this->hasOption('parser')) {
            $command += ['-p' => $this->getOption('parser')];
        }
        if (isset($target)) {
            // Need to use isset() with rollback, because -t0 is a valid option!
            // See http://docs.phinx.org/en/latest/commands.html#the-rollback-command
            $command += ['-t' => $target];
        }

        return $this->executeRun($command);
    }
1257860
protected function get_env_for_read_or_fail()
    {
        try {
            return File::at($this->resolve_file_path())->load();
        } catch (\Exception $e) {
            WP_CLI::error($e->getMessage());
        }
    }
1026453
public function getEnvCmd(string $env = 'WINDWALKER_MODE', string $value = 'dev'): string
    {
        $prefix = $this->environment->getPlatform()->isWin()
            ? 'set'
            : 'export';

        return sprintf('%s %s=%s', $prefix, $env, $value);
    }
507876
public function detectEnvironment($envs)
    {
        $args = isset($_SERVER['argv']) ? $_SERVER['argv'] : null;

        return $this['env'] = (new EnvironmentDetector())->detect($envs, $args);
    }
797765
public static function normalize($env)
    {
        $env += ['PHP_SAPI' => PHP_SAPI];

        if (isset($env['SCRIPT_URI'])) {
            $env['HTTPS'] = strpos($env['SCRIPT_URI'], 'https://') === 0;
        } elseif (isset($env['HTTPS'])) {
            $env['HTTPS'] = (!empty($env['HTTPS']) && $env['HTTPS'] !== 'off');
        }

        if (isset($env['HTTP_X_HTTP_METHOD_OVERRIDE'])) {
            $env['REQUEST_METHOD'] = $env['HTTP_X_HTTP_METHOD_OVERRIDE'];
        }

        if (isset($env['REDIRECT_HTTP_AUTHORIZATION'])) {
            $env['HTTP_AUTHORIZATION'] = $env['REDIRECT_HTTP_AUTHORIZATION'];
        }

        foreach (['HTTP_X_FORWARDED_FOR', 'HTTP_PC_REMOTE_ADDR', 'HTTP_X_REAL_IP'] as $key) {
            if (isset($env[$key])) {
                $addrs = explode(', ', $env[$key]);
                $env['REMOTE_ADDR'] = reset($addrs);
                break;
            }
        }

        if (empty($env['SERVER_ADDR']) && !empty($env['LOCAL_ADDR'])) {
            $env['SERVER_ADDR'] = $env['LOCAL_ADDR'];
        }

        if ($env['PHP_SAPI'] === 'isapi' && isset($env['PATH_TRANSLATED']) && isset($env['SCRIPT_NAME'])) {
            $env['SCRIPT_FILENAME'] = str_replace('\\\\', '\\', $env['PATH_TRANSLATED']);
            $env['DOCUMENT_ROOT'] = substr($env['SCRIPT_FILENAME'], 0, -strlen($env['SCRIPT_NAME']));
        }

        return $env;
    }
923401
public function dump($value, ?Enviroment $enviroment = null): string
    {

        $format = FormatFactory::factory($value);

        return $this->format($format, $enviroment);
    }
850246
protected function checkEnvVariable()
    {
        $key = $this->checkKey();
        $output = $this->execSSH("cd $this->domain;cat .env");
        if (str_contains($output, $key)) {
            $this->info("Key $key found in remote environment file");
        } else {
            $this->error("Key $key NOT found in remote environment file");
        }
    }
1089592
public function getCurrentDeployment(Environment $environment, $refresh = false)
    {
        $cacheKey = implode(':', ['current-deployment', $environment->project, $environment->id]);
        $data = $this->cache->fetch($cacheKey);
        if ($data === false || $refresh) {
            $deployment = $environment->getCurrentDeployment();
            $data = $deployment->getData();
            $data['_uri'] = $deployment->getUri();
            $this->cache->save($cacheKey, $data, $this->config->get('api.environments_ttl'));
        } else {
            $deployment = new EnvironmentDeployment($data, $data['_uri'], $this->getHttpClient(), true);
        }

        return $deployment;
    }
642858
public function moveTo(string $target): ?string
    {
        $ret = $this->handle->rpoplpush($this->name, $target);
        return (false === $ret) ? null : $ret;
    }
971614
public static function getEnv($variable = null) {
		$cmd = preg_match("/WIN/Ai", PHP_OS) ? 'set' : 'printenv';
		$output = self::run($cmd)->output;

		$env = [];

		foreach ($output as $line) {
			list($key, $value) = explode("=", $line, 2);

			if ($variable && strtolower($key) === strtolower($variable)) {
				return $value;
			}

			$env[$key] = $value;
		}

		return $env;
	}
653805
public function environment($site, $env)
    {
        $variables = array(
            'site' => $site,
            'env' => $env,
        );
        $request = $this->get(array('{+base_path}/sites/{site}/envs/{env}.json', $variables));
        return new Response\Environment($request);
    }
294553
public function getDifferenceBetweenBranches($targetBranch, $sourceBranch)
    {
    	$output = $this->git(sprintf('log %s..%s --date=%s --format=format:%s', $targetBranch, $sourceBranch, $this->dateFormat, $this->logFormat));
    	return $this->parseLogsIntoArray($output);
    }
401195
public function setEnvironments($env) {
    $envs = (explode('+', $env));
    while (!empty($envs)) {
      $_env = array_shift($envs);
      if (!$this->setEnvironment($_env)) {
        $msg = dt("Unable to locate an environment definition for '@env'.", ['@env' => $_env]);
        if (empty($envs)) {
          drush_log($msg, 'warning');
          return FALSE;
        }
        else {
          drush_log($msg, 'warning');
          if (!drush_confirm(dt("Do you want to process the other environments?"))) {
            return drush_user_abort(dt("Aborting."));
          }
        }
      }
    }

    return TRUE;
  }
873542
public function getMigrate($env = null, $target = null)
    {
        $command = ['migrate'];
        if ($env ?: $this->hasOption('environment')) {
            $command += ['-e' => $env ?: $this->getOption('environment')];
        }
        if ($this->hasOption('configuration')) {
            $command += ['-c' => $this->getOption('configuration')];
        }
        if ($this->hasOption('parser')) {
            $command += ['-p' => $this->getOption('parser')];
        }
        if ($target) {
            $command += ['-t' => $target];
        }

        return $this->executeRun($command);
    }
441933
public static function env(string $value = null, $fallback = '')
  {
    $val = getenv($value);

    if ($val == null || $val == '') return $fallback;
    return $fallback;
  }
829996
protected function rollbackFiles($remote_host, $remote_dir, $target_dir)
	{
		$this->log('rollbackFiles', LOG_DEBUG);

		$output = array();
		$return = null;
		$this->sshExec($remote_host, 'cd '. $remote_dir .'; rm -rf '. $target_dir, $output, $return);
	}
751740
public function getKey($env, $key)
	{
		$map = $this->getMap($env);

		return isset($map[$key]) ? $map[$key] : null;
	}