From c9759b19c0be24c2ca3c61866231973d7dca0f63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sun, 13 Oct 2013 13:30:55 -0200 Subject: [PATCH] Add List Environment command. mage list environments --- Mage/Command/BuiltIn/List.php | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Mage/Command/BuiltIn/List.php diff --git a/Mage/Command/BuiltIn/List.php b/Mage/Command/BuiltIn/List.php new file mode 100644 index 0000000..7a5e06d --- /dev/null +++ b/Mage/Command/BuiltIn/List.php @@ -0,0 +1,42 @@ +getConfig()->getArgument(1); + + try { + switch ($subCommand) { + case 'environments': + $this->_environment(); + break; + } + } catch (Exception $e) { + Mage_Console::output('' . $e->getMessage() . '', 1, 2); + } + } + + private function _environment() + { + $environments = array(); + $content = scandir('.mage/config/environment/'); + foreach ($content as $file) { + if (strpos($file, '.yml') !== false) { + $environments[] = str_replace('.yml', '', $file); + } + } + sort($environments); + + if (count($environments) > 0) { + Mage_Console::output('These are your configured environments:', 1, 1); + foreach ($environments as $environment) { + Mage_Console::output('* ' . $environment . '', 2, 1); + } + Mage_Console::output('', 1, 1); + + } else { + Mage_Console::output('You don\'t have any environment configured.', 1, 2); + } + } +} \ No newline at end of file