From 732cc20f1fe438037c1db28951dc181f08b30a36 Mon Sep 17 00:00:00 2001 From: Rodmen Date: Thu, 26 Jun 2014 11:05:00 -0300 Subject: [PATCH] add user data and message to lock command --- Mage/Command/BuiltIn/DeployCommand.php | 1 + Mage/Command/BuiltIn/LockCommand.php | 16 ++++++++++++++-- Mage/Command/BuiltIn/ReleasesCommand.php | 3 ++- Mage/Command/BuiltIn/RollbackCommand.php | 3 ++- Mage/Console.php | 15 ++++++++++++++- 5 files changed, 33 insertions(+), 5 deletions(-) diff --git a/Mage/Command/BuiltIn/DeployCommand.php b/Mage/Command/BuiltIn/DeployCommand.php index 63afdfb..0d2cb3d 100644 --- a/Mage/Command/BuiltIn/DeployCommand.php +++ b/Mage/Command/BuiltIn/DeployCommand.php @@ -104,6 +104,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment $lockFile = '.mage/' . $this->getConfig()->getEnvironment() . '.lock'; if (file_exists($lockFile)) { Console::output('This environment is locked!', 1, 2); + echo file_get_contents($lockFile); return; } diff --git a/Mage/Command/BuiltIn/LockCommand.php b/Mage/Command/BuiltIn/LockCommand.php index 3bd978e..ae33b39 100644 --- a/Mage/Command/BuiltIn/LockCommand.php +++ b/Mage/Command/BuiltIn/LockCommand.php @@ -27,10 +27,22 @@ class LockCommand extends AbstractCommand implements RequiresEnvironment */ public function run() { + Console::output('Your name (enter to leave blank): ', 0, 0); + $name = Console::readInput(); + Console::output('Your email (enter to leave blank): ', 0, 0); + $email = Console::readInput(); + Console::output('Reason of lock (enter to leave blank): ', 0, 0); + $reason = Console::readInput(); + + $lockmsg = PHP_EOL; + if ($name) $lockmsg .= 'Locked by ' . $name . ' '; + if ($email) $lockmsg .= '(' . $email . ')'; + if ($reason) $lockmsg .= PHP_EOL . $reason . PHP_EOL; + $lockFile = '.mage/' . $this->getConfig()->getEnvironment() . '.lock'; - file_put_contents($lockFile, 'Locked environment at date: ' . date('Y-m-d H:i:s')); + file_put_contents($lockFile, 'Locked environment at date: ' . date('Y-m-d H:i:s') . $lockmsg); Console::output('Locked deployment to ' . $this->getConfig()->getEnvironment() . ' environment', 1, 2); } -} \ No newline at end of file +} diff --git a/Mage/Command/BuiltIn/ReleasesCommand.php b/Mage/Command/BuiltIn/ReleasesCommand.php index 4d8eded..b1b4670 100644 --- a/Mage/Command/BuiltIn/ReleasesCommand.php +++ b/Mage/Command/BuiltIn/ReleasesCommand.php @@ -37,6 +37,7 @@ class ReleasesCommand extends AbstractCommand implements RequiresEnvironment $lockFile = '.mage/' . $this->getConfig()->getEnvironment() . '.lock'; if (file_exists($lockFile) && ($subcommand == 'rollback')) { Console::output('This environment is locked!', 1, 2); + echo file_get_contents($lockFile); return null; } @@ -70,4 +71,4 @@ class ReleasesCommand extends AbstractCommand implements RequiresEnvironment return $result; } -} \ No newline at end of file +} diff --git a/Mage/Command/BuiltIn/RollbackCommand.php b/Mage/Command/BuiltIn/RollbackCommand.php index 1b945ad..9f90959 100644 --- a/Mage/Command/BuiltIn/RollbackCommand.php +++ b/Mage/Command/BuiltIn/RollbackCommand.php @@ -37,6 +37,7 @@ class RollbackCommand extends AbstractCommand implements RequiresEnvironment $lockFile = '.mage/' . $this->getConfig()->getEnvironment() . '.lock'; if (file_exists($lockFile) && ($subcommand == 'rollback')) { Console::output('This environment is locked!', 1, 2); + echo file_get_contents($lockFile); return null; } @@ -59,4 +60,4 @@ class RollbackCommand extends AbstractCommand implements RequiresEnvironment return $result; } -} \ No newline at end of file +} diff --git a/Mage/Console.php b/Mage/Console.php index 04eade8..b629b9e 100644 --- a/Mage/Console.php +++ b/Mage/Console.php @@ -227,6 +227,18 @@ class Console return self::$logFile; } + /** + * Read String From Prompt + */ + public static function readInput() + { + $fp = fopen("php://stdin","r"); + $line = ''; + $line = fgets($fp); + + return rtrim($line); + } + /** * Check Logs * @param \Mage\Config $config @@ -252,4 +264,5 @@ class Console } } } -} \ No newline at end of file + +}