From 9b27dd8ebe1c97c7cb164297652881983cd65765 Mon Sep 17 00:00:00 2001 From: Andrs Montaez Date: Tue, 3 Jan 2012 23:54:57 -0200 Subject: [PATCH] New config settings. --- Mage/Config.php | 33 +++++++++++++++++++ Mage/Console.php | 25 +++++++++----- docs/example-config/.mage/config/general.yaml | 11 +++++++ 3 files changed, 60 insertions(+), 9 deletions(-) create mode 100644 docs/example-config/.mage/config/general.yaml diff --git a/Mage/Config.php b/Mage/Config.php index dedeb9c..9411470 100644 --- a/Mage/Config.php +++ b/Mage/Config.php @@ -3,6 +3,7 @@ class Mage_Config { private $_environment = null; private $_scm = null; + private $_general = null; private $_host = null; private $_releaseId = null; @@ -20,6 +21,13 @@ class Mage_Config } } + public function loadGeneral() + { + if (file_exists('.mage/config/general.yaml')) { + $this->_general = @yaml_parse_file('.mage/config/general.yaml'); + } + } + public function getEnvironment() { return $this->_environment; @@ -30,6 +38,11 @@ class Mage_Config return $this->_scm; } + public function getGlobal() + { + return $this->_global; + } + public function getHosts() { $config = $this->getEnvironment(); @@ -141,4 +154,24 @@ class Mage_Config return $default; } } + + public function general($option, $default = false) + { + $options = $this->_general; + if (isset($options[$option])) { + return $options[$option]; + } else { + return $default; + } + } + + public function mail($option, $default = false) + { + $options = $this->_general; + if (isset($options['mail'][$option])) { + return $options['mail'][$option]; + } else { + return $default; + } + } } \ No newline at end of file diff --git a/Mage/Console.php b/Mage/Console.php index b93dd8d..698be33 100644 --- a/Mage/Console.php +++ b/Mage/Console.php @@ -8,6 +8,7 @@ class Mage_Console private static $_log = null; private static $_logEnabled = true; private static $_screenBuffer = ''; + private static $_commandsOutput = ''; public function setArgs($args) { @@ -80,6 +81,7 @@ class Mage_Console if (!$return) { $output = trim($log); } + self::$_commandsOutput .= PHP_EOL . trim($log) . PHP_EOL; self::log($log); self::log('---------------------------------'); @@ -88,18 +90,23 @@ class Mage_Console } public function run() - { - // Disable Loging - if ($this->getAction() == 'install') { - self::$_logEnabled = false; - } - - Mage_Console::output('Starting Magallanes', 0, 2); - + { + // Load Config $config = new Mage_Config; + $config->loadGeneral(); $config->loadEnvironment($this->getEnvironment()); $config->loadSCM(); + // Logging + if ($this->getAction() == 'install') { + self::$_logEnabled = false; + } else { + self::$_logEnabled = $config->general('logging', false); + } + + // Grettings + Mage_Console::output('Starting Magallanes', 0, 2); + switch ($this->getAction()) { case 'deploy': $task = new Mage_Task_Deploy; @@ -148,7 +155,7 @@ class Mage_Console Mage_Console::output('Finished Magallanes', 0, 2); } - + public static function log($message, $continuation = false) { if (self::$_logEnabled) { diff --git a/docs/example-config/.mage/config/general.yaml b/docs/example-config/.mage/config/general.yaml new file mode 100644 index 0000000..45284ce --- /dev/null +++ b/docs/example-config/.mage/config/general.yaml @@ -0,0 +1,11 @@ +#general settings +logging: true +mail: + enabled: true + from: andresmontanez@gmail.com + password: xxxxxx + smtp: smtp.gmail.com + to: + - andresmontanez@gmail.com + - andres.montanez@zenreworks.com +