Allow environment to be passed to bin/gpm and bin/plugin commands

This commit is contained in:
Andy Miller 2016-09-01 15:44:43 -06:00
parent 9f2852a56e
commit 9b94ce6405
2 changed files with 33 additions and 3 deletions

18
bin/gpm
View File

@ -7,6 +7,7 @@ if (!file_exists(__DIR__ . '/../vendor')){
}
use Grav\Common\Composer;
use Grav\Common\Config\Setup;
if (!file_exists(__DIR__ . '/../vendor')){
// Before we can even start, we need to run composer first
@ -37,9 +38,24 @@ if (!function_exists('curl_version')) {
exit('FATAL: GPM requires PHP Curl module to be installed');
}
$climate = new League\CLImate\CLImate;
$climate->arguments->add([
'environment' => [
'prefix' => 'e',
'longPrefix' => 'env',
'description' => 'Configuration Environment',
'defaultValue' => 'localhost'
]
]);
$climate->arguments->parse();
$environment = $climate->arguments->get('environment');
// Set up environment based on params.
Setup::$environment = $environment;
$grav = Grav::instance(array('loader' => $autoload));
$grav['config']->init();
$grav['uri']->init();
$grav['config']->init();
$grav['streams'];
$app = new Application('Grav Package Manager', GRAV_VERSION);

View File

@ -38,15 +38,29 @@ if (!file_exists(ROOT_DIR . 'index.php')) {
exit('FATAL: Must be run from ROOT directory of Grav!');
}
// Set up environment.
Setup::$environment = 'localhost';
$climate = new League\CLImate\CLImate;
$climate->arguments->add([
'environment' => [
'prefix' => 'e',
'longPrefix' => 'env',
'description' => 'Configuration Environment',
'defaultValue' => 'localhost'
]
]);
$climate->arguments->parse();
$environment = $climate->arguments->get('environment');
// Set up environment based on params.
Setup::$environment = $environment;
$grav = Grav::instance(array('loader' => $autoload));
$grav['uri']->init();
$grav['config']->init();
$grav['streams'];
$grav['plugins']->init();
$grav['themes']->init();
$app = new Application('Grav Plugins Commands', GRAV_VERSION);
$pattern = '([A-Z]\w+Command\.php)';