mirror of https://github.com/hauke68/Magallanes
Andrs Montaez
13 years ago
13 changed files with 174 additions and 93 deletions
@ -0,0 +1,7 @@ |
|||||||
|
.project |
||||||
|
.buildpath |
||||||
|
.settings |
||||||
|
.settings/* |
||||||
|
.settings/org.eclipse.php.core.prefs |
||||||
|
|
||||||
|
.settings/org.eclipse.php.core.prefs |
@ -1,53 +1,42 @@ |
|||||||
<?php |
<?php |
||||||
class Mage_Console_Colors { |
class Mage_Console_Colors |
||||||
private static $foreground_colors = array (); |
{ |
||||||
private static $background_colors = array (); |
private static $foreground_colors = array( |
||||||
|
'black' => '0;30', |
||||||
|
'dark_gray' => '1;30', |
||||||
|
'blue' => '0;34', |
||||||
|
'light_blue' => '1;34', |
||||||
|
'green' => '0;32', |
||||||
|
'light_green' => '1;32', |
||||||
|
'cyan' => '0;36', |
||||||
|
'light_cyan' => '1;36', |
||||||
|
'red' => '0;31', |
||||||
|
'light_red' => '1;31', |
||||||
|
'purple' => '0;35', |
||||||
|
'light_purple' => '1;35', |
||||||
|
'brown' => '0;33', |
||||||
|
'yellow' => '1;33', |
||||||
|
'light_gray' => '0;37', |
||||||
|
'white' => '1;37' |
||||||
|
|
||||||
public function __construct() { |
); |
||||||
// Set up shell colors |
|
||||||
self::$foreground_colors ['black'] = '0;30'; |
|
||||||
self::$foreground_colors ['dark_gray'] = '1;30'; |
|
||||||
self::$foreground_colors ['blue'] = '0;34'; |
|
||||||
self::$foreground_colors ['light_blue'] = '1;34'; |
|
||||||
self::$foreground_colors ['green'] = '0;32'; |
|
||||||
self::$foreground_colors ['light_green'] = '1;32'; |
|
||||||
self::$foreground_colors ['cyan'] = '0;36'; |
|
||||||
self::$foreground_colors ['light_cyan'] = '1;36'; |
|
||||||
self::$foreground_colors ['red'] = '0;31'; |
|
||||||
self::$foreground_colors ['light_red'] = '1;31'; |
|
||||||
self::$foreground_colors ['purple'] = '0;35'; |
|
||||||
self::$foreground_colors ['light_purple'] = '1;35'; |
|
||||||
self::$foreground_colors ['brown'] = '0;33'; |
|
||||||
self::$foreground_colors ['yellow'] = '1;33'; |
|
||||||
self::$foreground_colors ['light_gray'] = '0;37'; |
|
||||||
self::$foreground_colors ['white'] = '1;37'; |
|
||||||
|
|
||||||
self::$background_colors ['black'] = '40'; |
// Returns colored string |
||||||
self::$background_colors ['red'] = '41'; |
public static function color($string) |
||||||
self::$background_colors ['green'] = '42'; |
{ |
||||||
self::$background_colors ['yellow'] = '43'; |
foreach (self::$foreground_colors as $key => $code) { |
||||||
self::$background_colors ['blue'] = '44'; |
$replaceFrom = array( |
||||||
self::$background_colors ['magenta'] = '45'; |
'<' . $key . '>', |
||||||
self::$background_colors ['cyan'] = '46'; |
'</' . $key . '>' |
||||||
self::$background_colors ['light_gray'] = '47'; |
); |
||||||
} |
$replaceTo = array( |
||||||
|
"\033[" . $code . 'm', |
||||||
|
"\033[0m" |
||||||
|
); |
||||||
|
|
||||||
// Returns colored string |
$string = str_replace($replaceFrom, $replaceTo, $string); |
||||||
public static function g($string, $foreground_color = null, $background_color = null) { |
} |
||||||
$colored_string = ""; |
|
||||||
|
|
||||||
// Check if given foreground color found |
return $string; |
||||||
if (isset ( self::$foreground_colors [$foreground_color] )) { |
} |
||||||
$colored_string .= "\033[" . self::$foreground_colors [$foreground_color] . "m"; |
|
||||||
} |
|
||||||
// Check if given background color found |
|
||||||
if (isset ( self::$background_colors [$background_color] )) { |
|
||||||
$colored_string .= "\033[" . self::$background_colors [$background_color] . "m"; |
|
||||||
} |
|
||||||
|
|
||||||
// Add string and end coloring |
|
||||||
$colored_string .= $string . "\033[0m"; |
|
||||||
|
|
||||||
return $colored_string; |
|
||||||
} |
|
||||||
} |
} |
||||||
|
@ -1,17 +1,33 @@ |
|||||||
<?php |
<?php |
||||||
abstract class Mage_Task_TaskAbstract |
abstract class Mage_Task_TaskAbstract |
||||||
{ |
{ |
||||||
|
protected $_config = null; |
||||||
|
|
||||||
public abstract function getName(); |
public abstract function getName(); |
||||||
|
|
||||||
public abstract function run($config); |
public abstract function run(); |
||||||
|
|
||||||
|
public final function __construct($config) |
||||||
|
{ |
||||||
|
$this->_config = $config; |
||||||
|
} |
||||||
|
|
||||||
|
public function init() |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
protected function _runLocalCommand($command) |
protected final function _runLocalCommand($command) |
||||||
{ |
{ |
||||||
return Mage_Console::executeCommand($command); |
return Mage_Console::executeCommand($command); |
||||||
} |
} |
||||||
|
|
||||||
protected function _runRemoteCommand($command) |
protected final function _runRemoteCommand($command) |
||||||
{ |
{ |
||||||
|
$localCommand = 'ssh ' |
||||||
|
. $this->_config['deploy']['user'] . '@' . $this->_config['deploy']['host'] . ' ' |
||||||
|
. '"cd ' . $this->_config['deploy']['deploy-to'] . ' && ' |
||||||
|
. $command . '"'; |
||||||
|
|
||||||
|
return $this->_runLocalCommand($localCommand); |
||||||
} |
} |
||||||
} |
} |
@ -0,0 +1,24 @@ |
|||||||
|
<?php |
||||||
|
class Mage_Task_Update |
||||||
|
{ |
||||||
|
private $_config = null; |
||||||
|
|
||||||
|
public function run(Mage_Config $config) |
||||||
|
{ |
||||||
|
$this->_config = $config; |
||||||
|
|
||||||
|
$taskConfig = $config->getConfig(); |
||||||
|
$task = Mage_Task_Factory::get('scm/update', $taskConfig); |
||||||
|
$task->init(); |
||||||
|
|
||||||
|
Mage_Console::output( PHP_TAB . 'Updating application via ' . $task->getName() . ' ... '); |
||||||
|
$result = $task->run(); |
||||||
|
|
||||||
|
if ($result == true) { |
||||||
|
Mage_Console::output(PHP_TAB . 'OK' . PHP_EOL); |
||||||
|
} else { |
||||||
|
Mage_Console::output(PHP_TAB . 'FAIL' . PHP_EOL); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue