2016-11-13 16:06:29 +07:00
|
|
|
<?php
|
2016-11-19 15:13:32 +07:00
|
|
|
/* (c) Anton Medvedev <anton@medv.io>
|
2016-11-13 16:06:29 +07:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Deployer;
|
|
|
|
|
|
|
|
use Deployer\Task\Context;
|
|
|
|
use Symfony\Component\Console\Helper\Table;
|
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
|
|
|
|
|
|
|
desc('Print server configuration');
|
|
|
|
task('config:dump', function () {
|
|
|
|
$server = Context::get()->getServer();
|
|
|
|
$config = Deployer::get()->config;
|
|
|
|
$env = Context::get()->getEnvironment();
|
|
|
|
$dump = [];
|
|
|
|
|
|
|
|
foreach ($config as $name => $value) {
|
|
|
|
try {
|
|
|
|
$env->get($name);
|
|
|
|
} catch (\RuntimeException $exception) {
|
|
|
|
// Ignore fails.
|
|
|
|
$message = 'Failed to dump';
|
|
|
|
$env->set($name, output()->isDecorated() ? "\033[1;30m$message\033[0m" : $message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($env->getValues() as $name => $value) {
|
|
|
|
if (is_array($value)) {
|
|
|
|
$value = json_encode($value);
|
|
|
|
} elseif (is_bool($value)) {
|
|
|
|
$value = $value ? 'Yes' : 'No';
|
|
|
|
}
|
|
|
|
|
|
|
|
$dump[] = [$name, $value];
|
|
|
|
}
|
|
|
|
|
|
|
|
$io = new SymfonyStyle(input(), output());
|
|
|
|
$io->section("[{$server->getConfiguration()->getName()}] {$server->getConfiguration()->getHost()}");
|
|
|
|
|
|
|
|
$table = new Table(output());
|
|
|
|
$table
|
|
|
|
->setHeaders(['Parameter', 'Value',])
|
|
|
|
->setRows($dump);
|
|
|
|
$table->render();
|
|
|
|
});
|