deployer/recipe/config/current.php
Kyle Tucker 6180366acf Update config:hosts and config:current task recipes (#1901)
* Update config:hosts and config:current task recipes

* Update changelog

* Fix variable refs
2019-08-09 22:16:00 +03:00

42 lines
1.0 KiB
PHP

<?php
/* (c) Anton Medvedev <anton@medv.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Deployer;
use Deployer\Host\Host;
use Symfony\Component\Console\Helper\Table;
desc('Show current paths');
task('config:current', function () {
$rows = [];
$selectedStage = Deployer::get()->getInput()->getArgument('stage');
on(Deployer::get()->hosts, function (Host $host) use (&$rows, $selectedStage) {
if ($host->get('stage') !== $selectedStage) {
return;
}
try {
$rows[] = [
$host->getHostname(),
basename($host->get('current_path')),
];
} catch (\Throwable $e) {
$rows[] = [
$host->getHostname(),
'unknown',
];
}
});
$table = new Table(output());
$table
->setHeaders(['Host', 'Current',])
->setRows($rows);
$table->render();
})->local();