Returns the output from running the "seed:run" command.
@param  string|null       $env environment name
@param  string|null       $target target version
@param  array|string|null $seed array of seed names or seed name
@return string
765368
public function getSeed($env = null, $target = null, $seed = null)
    {
        $command = ['seed:run'];
        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];
        }
        if ($seed) {
            $seed = (array)$seed;
            $command += ['-s' => $seed];
        }

        return $this->executeRun($command);
    }
599400
public static function setDriver($driver, $env = null)
    {
        $file = realpath(dirname(__FILE__)."/../drivers/$driver.php");
        if (!file_exists($file)) {
            Log::log("ERROR: Driver file $file does not exists");
            return null;
        }
        self::$_driver[self::selectEnvironment($env)] = $driver;
        include_once $file;
    }
1170245
public function run_command($command) {
        \Log::debug($command);

        $descriptorspec = array(
            1 => array('pipe', 'w'),
            2 => array('pipe', 'w'),
        );
        $pipes = array();
        /* Depending on the value of variables_order, $_ENV may be empty.
         * In that case, we have to explicitly set the new variables with
         * putenv, and call proc_open with env=null to inherit the reset
         * of the system.
         *
         * This is kind of crappy because we cannot easily restore just those
         * variables afterwards.
         *
         * If $_ENV is not empty, then we can just copy it and be done with it.
         */
        if(count($_ENV) === 0) {
            $env = NULL;
            foreach($this->envopts as $k => $v) {
                putenv(sprintf("%s=%s",$k,$v));
            }
        } else {
            $env = array_merge($_ENV, $this->envopts);
        }
        $cwd = $this->repo_path;
        $resource = proc_open($command, $descriptorspec, $pipes, $cwd, $env);

        $stdout = stream_get_contents($pipes[1]);
        $stderr = stream_get_contents($pipes[2]);
        foreach ($pipes as $pipe) {
            fclose($pipe);
        }

        $status = trim(proc_close($resource));
        if ($status) throw new Exception($stderr);

        return $stdout;
    }
703154
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $message = "WARNING! You are about to execute a database seed operation "
            ."that could result data lost.\n Do you wish to continue?";

        if (! $this->confirm($message))
        {
            $this->error('Process aborted!');
            exit(3);
        }
        try
        {
          $filename = ucfirst($this->getArgument('name'));
          $appPath  = realpath(getenv('APPPATH'));
          $appDir   = basename($appPath);

          if (file_exists($file = sprintf('%s/seeders/%s.php', $appPath, $filename)))
          {
            require_once $file;
          }
          else
          {
            throw new \RuntimeException('Seeder does not exist.');
          }

          $obj = new $filename(new Codeigniter);
          $obj->db->queries = [];

          if (! method_exists($obj, 'run'))
          {
            throw new \RuntimeException(sprintf(
              '[%s] Seeder class does not contain a Seeder::run method',
              $filename
            ));
          }

          $case = 'seeding';
          $signal = '++';

          $this->newLine();
          $this->text(sprintf('<info>%s</info> %s', $signal, $case));

          $time_start = microtime(true);

          $obj->run();

          $time_end = microtime(true);

          list($query_exec_time, $exec_queries) = $this->measureQueries($obj->db->queries, $obj->db->query_times);

          $this->summary($signal, $time_start, $time_end, $query_exec_time, $exec_queries);
        }
        catch (\Exception $e)
        {
            $this->error($e->getMessage());
        }
    }
751740
public function getKey($env, $key)
	{
		$map = $this->getMap($env);

		return isset($map[$key]) ? $map[$key] : null;
	}
589981
private function generateSnippet(Environment $environment, StepNode $step)
    {
        foreach ($this->generators as $generator) {
            if ($generator->supportsEnvironmentAndStep($environment, $step)) {
                return $generator->generateSnippet($environment, $step);
            }
        }

        return null;
    }
1139000
public function setEnv($env_name, $config)
    {
        $method = 'setClient'.ucfirst(strtolower($env_name));
        $property = 'client_'.strtolower($env_name);
        $set_value = (getenv($this->env_name.strtoupper($env_name))) ? getenv($this->env_name.strtoupper($env_name)) : '';
        if (isset($config[$env_name])) {
            $set_value = $config[$env_name];
        }
        if (!empty($set_value)) {
            if (method_exists($this, $method)) {
                return $this->$method($set_value);
            } elseif (property_exists($this, $property)) {
                $this->$property = $set_value;
            }
        }
        return $this;
    }
548041
public function ciShell($environment, $args = '')
    {
        $runner = new Runner($environment);

        $res = $runner->buildImage();
        if (!$res->wasSuccessful()) return 1;
        $runner->runServices();

        $links = array_keys($runner->getServices());
        $links = implode(' ', array_map(function($l) {return "--link $l";}, $links ));

        $command = (new DockerRun(Config::$runImage))
            ->option('-t')
            ->option('-i')
            ->name('robo_shell_'.uniqid())
            ->arg($links)
            ->arg($args)
            ->exec('bash')
            ->getCommand();

        $this->yell("To enter shell run `$command`\n");
    }
409394
protected function getenv($varname): ?string
    {
        $value = getenv($varname, true);

        if ($value === false) {
            $value = getenv($varname);
        }

        return $value !== false ? $value : null;
    }
78581
public function get($key, $env = NULL)
    {
        if (!$env) {
            $env = self::$current_env;
        }

        return isset(self::$params[$env][$key]) ? self::$params[$env][$key] : NULL;
    }
681127
public function extract($source, $target)
    {
        if (!$sourceRes = gzopen($source, 'r')) {
            throw new \RuntimeException(sprintf('Unable to read archive file "%s".', $source));
        }
        if (!$targetRes = fopen($target, 'w')) {
            throw new \RuntimeException(sprintf('Unable to write target file "%s".', $target));
        }
        while (!gzeof($sourceRes)) {
            fwrite($targetRes, gzread($sourceRes, $this->bufferSize));
        }
        if (!gzclose($sourceRes)) {
            throw new \RuntimeException(sprintf('Unable to close archive file "%s".', $source));
        }
        if (!fclose($targetRes)) {
            throw new \RuntimeException(sprintf('Unable to close target file "%s".', $target));
        }
    }
1173619
protected function getValue($value, $env_var, $command)
    {
        if ($this->argument($value)) {
            return $this->argument($value);
        } else {
            return fp_env($env_var) ? fp_env($env_var) : $this->call("publish:$command");
        }
    }
976383
public function dump(Environment $env, $context)
    {
        if (!$this->isEnabled($env)) {
            return null;
        }

        if (func_num_args() === 2) {
            $vars = [];
            foreach ($context as $key => $value) {
                if (!$value instanceof Template) {
                    $vars[$key] = $value;
                }
            }

            $vars = [$vars];
        } else {
            $vars = func_get_args();
            unset($vars[0], $vars[1]);
        }

        $output = fopen('php://memory', 'r+b');
        $this->dumper->setCharset($env->getCharset());

        foreach ($vars as $value) {
            $this->dumper->dump($this->cloner->cloneVar($value), $output);
        }

        return stream_get_contents($output, -1, 0);
    }
425176
protected function _runCmd($cmd, $content, $environment = null)
    {
        $Process = new AssetProcess();
        $Process->environment($environment);
        $Process->command($cmd)->run($content);

        if ($Process->error()) {
            throw new RuntimeException($Process->error());
        }
        return $Process->output();
    }
687282
public function getNumber($command, $target = null, $value = null)
    {
        $string = $this->getString($command, $target, $value);

        return (int) $string;
    }
15861
public function getCoreErrors($env = null)
    {
        $env = $env ?: $this->running_env;
        return isset($this->errors[$env]) ? $this->errors[$env] : 0;
    }
1328157
private function getEnv($id = null)
    {
        $string = file_get_contents($this->env);
        $string = preg_split('/\n+/', $string);
        $array = [];
        foreach ($string as $k => $one) {
            if (preg_match('/^(#\s)/', $one) === 1 || preg_match('/^([\\n\\r]+)/', $one)) {
                continue;
            }
            $entry = explode("=", $one, 2);
            if (!empty($entry[0])) {
                $array[] = ['id' => $k + 1, 'key' => $entry[0], 'value' => isset($entry[1]) ? $entry[1] : null];
            }
        }
        if (empty($id)) {
            return $array;
        }
        $index = array_search($id, array_column($array, 'id'));

        return $array[$index];
    }