mirror of https://github.com/hauke68/Magallanes
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
1.6 KiB
75 lines
1.6 KiB
13 years ago
|
<?php
|
||
13 years ago
|
class Mage_Console
|
||
13 years ago
|
{
|
||
|
private $_args;
|
||
|
private $_action;
|
||
|
private $_actionOptions;
|
||
|
private $_environment;
|
||
|
|
||
|
public function setArgs($args)
|
||
|
{
|
||
|
$this->_args = $args;
|
||
|
array_shift($this->_args);
|
||
|
}
|
||
|
|
||
|
public function parse()
|
||
|
{
|
||
|
foreach ($this->_args as $argument) {
|
||
|
if ($argument == 'deploy') {
|
||
|
$this->_action = 'deploy';
|
||
|
|
||
|
} else if ($argument == 'update') {
|
||
|
$this->_action = 'update';
|
||
|
|
||
|
} else if (preg_match('/to:[\w]+/i', $argument)) {
|
||
|
$this->_environment = str_replace('to:', '', $argument);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function getAction()
|
||
|
{
|
||
|
return $this->_action;
|
||
|
}
|
||
|
|
||
|
public function getEnvironment()
|
||
|
{
|
||
|
return $this->_environment;
|
||
|
}
|
||
|
|
||
|
public static function output($message)
|
||
|
{
|
||
|
echo $message;
|
||
|
}
|
||
|
|
||
13 years ago
|
public static function executeCommand($command)
|
||
|
{
|
||
|
ob_start();
|
||
|
system($command . ' 2>&1', $return);
|
||
|
$log = ob_get_clean();
|
||
|
|
||
|
return !$return;
|
||
|
}
|
||
|
|
||
13 years ago
|
public function run()
|
||
|
{
|
||
13 years ago
|
$config = new Mage_Config;
|
||
|
$config->loadEnvironment($this->getEnvironment());
|
||
|
$config->loadSCM();
|
||
13 years ago
|
|
||
|
switch ($this->getAction()) {
|
||
|
case 'deploy':
|
||
13 years ago
|
$task = new Mage_Task_Deploy;
|
||
|
$task->run($config);
|
||
13 years ago
|
break;
|
||
|
|
||
|
case 'update';
|
||
|
$config->loadCSM();
|
||
13 years ago
|
$task = new Mage_Task_Update;
|
||
|
$task->run($config);
|
||
13 years ago
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
define('PHP_TAB', "\t");
|