Get the enviornment argument from the console.

@param   array  $args
@return  mixed  string|null
351886
protected function getEnvironmentArgument(array $args)
	{
		foreach ($args as $k => $v)
		{
			if (substr($v, 0, strlen('--env')) == '--env')
			{
				return $v;
			}
		}

		return null;
	}
698663
public function getCommand( $args )
    {
        $class = strtoupper( substr( $args[ 1 ], 0, 1 ) ) . substr( $args[ 1 ], 1 );
        $class .= 'Command';

        /** @var Command $command */
        $command = NULL;

        if ( class_exists( $class ) )
        {
            $command = new $class();
        }

        if ( NULL === $command && !empty( $this->namespaces ) )
        {
            foreach ( $this->namespaces as $ns )
            {
                $name = $ns . $class;

                if ( class_exists( $name ) )
                {
                    $command = new $name();
                    $command->init( $args );

                    break;
                }
            }
        }

        if ( NULL !== $command )
        {
            $command->configure();
        }

        return $command;
    }
767985
public function getEnvironment($name)
    {
        return isset($this->environments[$name]) ? $this->environments[$name] : null;
    }
650901
private function parseArgs(array $args)
    {
        if (! count($args)) {
            return $this->createHelpArgument();
        }

        $arg1 = array_shift($args);

        if (in_array($arg1, ['-h', '--help', 'help'], true)) {
            return $this->createHelpArgument();
        }

        if (! count($args)) {
            return $this->createErrorArgument('Missing class name');
        }

        $configFile = $arg1;
        switch (file_exists($configFile)) {
            case true:
                $config = require $configFile;

                if (! is_array($config)) {
                    return $this->createErrorArgument(sprintf(
                        'Configuration at path "%s" does not return an array.',
                        $configFile
                    ));
                }

                break;
            case false:
                // fall-through
            default:
                if (! is_writable(dirname($configFile))) {
                    return $this->createErrorArgument(sprintf(
                        'Cannot create configuration at path "%s"; not writable.',
                        $configFile
                    ));
                }

                $config = [];
                break;
        }

        $class = array_shift($args);

        if (! class_exists($class)) {
            return $this->createErrorArgument(sprintf(
                'Class "%s" does not exist or could not be autoloaded.',
                $class
            ));
        }

        return $this->createArguments(self::COMMAND_DUMP, $configFile, $config, $class);
    }
1087440
public function checkModelName(array $args)
    {
        $arg1 = self::getExprAttr($args[0], 'value', 'value');
        if ($arg1 && is_string($arg1)) {
            $model = ['path' => null, 'name' => $arg1];
            if ($pos = strrpos($arg1, '/')) {
                $model['path'] = substr($arg1, 0, $pos);
                $model['name'] = substr($arg1, $pos + 1);
            }
            $this->model_names[] = $model;
            return $model;
        }
    }
883896
private function getSelectedModules(Args $args)
    {
        $states = $this->getSelectedStates($args);
        $expr = Expr::true();
        $envs = array();

        if ($states !== ModuleState::all()) {
            $expr = $expr->andMethod('getState', Expr::in($states));
        }

        if ($args->isOptionSet('installer')) {
            $expr = $expr->andMethod('getInstallInfo', Expr::method('getInstallerName', Expr::same($args->getOption('installer'))));
        }

        if ($args->isOptionSet('prod')) {
            $envs[] = Environment::PROD;
        }

        if ($args->isOptionSet('dev')) {
            $envs[] = Environment::DEV;
        }

        if (count($envs) > 0) {
            $expr = $expr->andMethod('getInstallInfo', Expr::method('getEnvironment', Expr::in($envs)));
        }

        return $this->moduleManager->findModules($expr);
    }
1251044
protected function getSplatCallVars($args)
    {
        $isSplatCall = false;
        $variables = [];
        foreach ($args as $arg) {
            if ($arg->unpack) {
                $isSplatCall = true;
            }
            $variables[] = $arg->value;
        }
        if (! $isSplatCall) {
            return;
        }
        return $variables;
    }
1160415
private function getEnvironment()
  {
    $env = new \Dotenv\Dotenv($this->basePath);
    $env->load();
    $this->env['env'] = getenv('APP_ENV');
    $this->env['debug'] = getenv('APP_DEBUG');
    $this->env['appSecret'] = getenv('APP_KEY');
  }
203507
public function getEnvBaseUrl($env)
    {
        switch ($env) {
            case self::ENV_PROD:
                return self::BASE_URL_PROD;
            case self::ENV_STAGE:
                return self::BASE_URL_STAGE;
            case self::ENV_MOCK:
                return null;
        }
    }
509599
private function getParams(array $args)
    {
        if (count($args) == 0) {
            return [];
        }

        $params = array_slice($args, -1)[0];

        return is_array($params) ? $params : [];
    }
274614
public function handleInstall(Args $args)
    {
        $moduleName = $args->getArgument('name');
        $installPath = Path::makeAbsolute($args->getArgument('path'), getcwd());
        $installer = $args->getOption('installer');
        $env = $args->isOptionSet('dev') ? Environment::DEV : Environment::PROD;

        $this->moduleManager->installModule($installPath, $moduleName, $installer, $env);

        return 0;
    }
1346734
protected function parseArgs($args)
    {
        if (!is_array($args)) {
            return $args;
        }

        $this->silent = in_array('--silent', $args);
        if ($this->silent) {
            $args = array_values(array_diff($args, ['--silent']));
        }

        return $args;
    }
476556
public function detect($environments, $consoleArgs = null)
	{
		if ($consoleArgs)
		{
			return $this->detectConsoleEnvironment($environments, $consoleArgs);
		}
		else
		{
			return $this->detectWebEnvironment($environments);
		}
	}
416971
public function env($name)
    {
        return isset($this->_envs[$name])
            ? $this->_envs[$name]
            : null;
    }
1101953
protected static function instanceKey($args = null)
    {
        $class = self::className();

        if (is_array($args))
        {
            $instanceKey = md5(json_encode($args));
        }
        elseif ($args === null)
        {
            $instanceKey = 'default';
        }
        else
        {
            $instanceKey = (string) $args;
        }
        $instanceKey = $class . ':' . $instanceKey;

        return $instanceKey;
    }
36812
protected function arguments(array $arguments = null)
    {
        return is_null($arguments)
            ? $this->arguments
            : ($this->arguments = $arguments);
    }
423877
public static function setEnvironment($environmentArg)
    {
        $environmentArg = strtolower(trim($environmentArg));

        $aliases = [
            \Genesis\API\Constants\Environments::STAGING    => [
                'test',
                'testing',
                'staging',
                \Genesis\API\Constants\Environments::STAGING
            ],
            \Genesis\API\Constants\Environments::PRODUCTION => [
                'live',
                'prod',
                'production',
                \Genesis\API\Constants\Environments::PRODUCTION
            ]
        ];

        foreach ($aliases as $environment => $endpointAlias) {
            foreach ($endpointAlias as $alias) {
                if (stripos($environmentArg, $alias) !== false) {
                    return self::$vault['environment'] = $environment;
                }
            }
        }

        throw new \Genesis\Exceptions\InvalidArgument(
            'Invalid Environment'
        );
    }